Browse Source

Finalized tutorial 701, added missing template

Former-commit-id: 63ef13a583853733e61ede308ca0a26e82912f60
koch 9 years ago
parent
commit
9e91b44667

+ 1 - 0
include/igl/parula.cpp

@@ -69,4 +69,5 @@ template void igl::parula<double>(double, double*);
 template void igl::parula<double>(double, double&, double&, double&);
 template void igl::parula<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 template void igl::parula<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template void igl::parula<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, double, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 1 - 1
python/modules/py_vector.cpp

@@ -149,11 +149,11 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
         .def("mean", [](const Type &m) {return m.mean();})
 
         .def("sum", [](const Type &m) {return m.sum();})
-        .def("square", [](const Type &m) {return m.array().square();})
         .def("prod", [](const Type &m) {return m.prod();})
         .def("trace", [](const Type &m) {return m.trace();})
         .def("norm", [](const Type &m) {return m.norm();})
         .def("squaredNorm", [](const Type &m) {return m.squaredNorm();})
+        .def("squaredMean", [](const Type &m) {return m.array().square().mean();})
 
         .def("minCoeff", [](const Type &m) {return m.minCoeff();} )
         .def("maxCoeff", [](const Type &m) {return m.maxCoeff();} )

+ 3 - 6
python/tutorial/701_Statistics.py

@@ -36,10 +36,7 @@ if __name__ == "__main__":
     area_min = area.minCoeff() / area_avg
     area_max = area.maxCoeff() / area_avg
     area_ns = (area - area_avg) / area_avg
-    print(area_ns[0])
-    # area_ns *= area_ns
-    print(area_ns[0])
-    area_sigma = math.sqrt(area_ns.mean())
+    area_sigma = math.sqrt(area_ns.squaredMean())
 
     print("Areas (Min/Max)/Avg_Area Sigma: \n%.2f/%.2f (%.2f)\n" % (
         area_min, area_max, area_sigma))
@@ -52,8 +49,8 @@ if __name__ == "__main__":
     angle_avg = angles.mean()
     angle_min = angles.minCoeff()
     angle_max = angles.maxCoeff()
-    angle_ns = (angles - angle_avg) * (angles - angle_avg)
-    angle_sigma = math.sqrt(angle_ns.mean())
+    angle_ns = angles - angle_avg
+    angle_sigma = math.sqrt(angle_ns.squaredMean())
 
     print("Angles in degrees (Min/Max) Sigma: \n%.2f/%.2f (%.2f)\n" % (
         angle_min, angle_max, angle_sigma))

+ 1 - 6
tutorial/701_Statistics/main.cpp

@@ -36,12 +36,7 @@ int main(int argc, char *argv[])
   double area_avg   = area.mean();
   double area_min   = area.minCoeff() / area_avg;
   double area_max   = area.maxCoeff() / area_avg;
-  auto area_ns = ((area.array()-area_avg)/area_avg);
-
-  std::cout << area_ns(0) << std::endl;
-//  area_ns.square();
-  std::cout << area_ns(0) << std::endl;
-  double area_sigma = sqrt(area_ns.square().mean());
+  double area_sigma = sqrt(((area.array()-area_avg)/area_avg).square().mean());
 
   printf("Areas (Min/Max)/Avg_Area Sigma: \n%.2f/%.2f (%.2f)\n",
     area_min,area_max,area_sigma);