Browse Source

componentwise_mult()

David Rose 11 years ago
parent
commit
5d5150c5aa

+ 24 - 0
panda/src/linmath/lmatrix3_src.I

@@ -943,6 +943,30 @@ operator /= (FLOATTYPE scalar) {
   return *this;
   return *this;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::componentwise_mult
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH void FLOATNAME(LMatrix3)::
+componentwise_mult(const FLOATNAME(LMatrix3) &other) {
+#ifdef HAVE_EIGEN
+  _v = _v.cwiseProduct(other._v);
+#else
+  _m(0, 0) *= other._m(0, 0);
+  _m(0, 1) *= other._m(0, 1);
+  _m(0, 2) *= other._m(0, 2);
+
+  _m(1, 0) *= other._m(1, 0);
+  _m(1, 1) *= other._m(1, 1);
+  _m(1, 2) *= other._m(1, 2);
+
+  _m(2, 0) *= other._m(2, 0);
+  _m(2, 1) *= other._m(2, 1);
+  _m(2, 2) *= other._m(2, 2);
+#endif  // HAVE_EIGEN
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix3::transpose_from
 //     Function: LMatrix3::transpose_from
 //       Access: Published
 //       Access: Published

+ 2 - 0
panda/src/linmath/lmatrix3_src.h

@@ -175,6 +175,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LMatrix3) &operator *= (FLOATTYPE scalar);
   INLINE_LINMATH FLOATNAME(LMatrix3) &operator *= (FLOATTYPE scalar);
   INLINE_LINMATH FLOATNAME(LMatrix3) &operator /= (FLOATTYPE scalar);
   INLINE_LINMATH FLOATNAME(LMatrix3) &operator /= (FLOATTYPE scalar);
 
 
+  INLINE_LINMATH void componentwise_mult(const FLOATNAME(LMatrix3) &other);
+
   INLINE_LINMATH FLOATTYPE determinant() const;
   INLINE_LINMATH FLOATTYPE determinant() const;
 
 
   INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix3) &other);
   INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix3) &other);

+ 32 - 0
panda/src/linmath/lmatrix4_src.I

@@ -1245,6 +1245,38 @@ operator /= (FLOATTYPE scalar) {
   return operator *= (recip_scalar);
   return operator *= (recip_scalar);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::componentwise_mult
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH void FLOATNAME(LMatrix4)::
+componentwise_mult(const FLOATNAME(LMatrix4) &other) {
+#ifdef HAVE_EIGEN
+  _v = _v.cwiseProduct(other._v);
+#else
+  _m(0, 0) *= other._m(0, 0);
+  _m(0, 1) *= other._m(0, 1);
+  _m(0, 2) *= other._m(0, 2);
+  _m(0, 3) *= other._m(0, 3);
+
+  _m(1, 0) *= other._m(1, 0);
+  _m(1, 1) *= other._m(1, 1);
+  _m(1, 2) *= other._m(1, 2);
+  _m(1, 3) *= other._m(1, 3);
+
+  _m(2, 0) *= other._m(2, 0);
+  _m(2, 1) *= other._m(2, 1);
+  _m(2, 2) *= other._m(2, 2);
+  _m(2, 3) *= other._m(2, 3);
+
+  _m(3, 0) *= other._m(3, 0);
+  _m(3, 1) *= other._m(3, 1);
+  _m(3, 2) *= other._m(3, 2);
+  _m(3, 3) *= other._m(3, 3);
+#endif  // HAVE_EIGEN
+}
+
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::transpose_from
 //     Function: LMatrix4::transpose_from

+ 2 - 0
panda/src/linmath/lmatrix4_src.h

@@ -177,6 +177,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LMatrix4) &operator *= (FLOATTYPE scalar);
   INLINE_LINMATH FLOATNAME(LMatrix4) &operator *= (FLOATTYPE scalar);
   INLINE_LINMATH FLOATNAME(LMatrix4) &operator /= (FLOATTYPE scalar);
   INLINE_LINMATH FLOATNAME(LMatrix4) &operator /= (FLOATTYPE scalar);
 
 
+  INLINE_LINMATH void componentwise_mult(const FLOATNAME(LMatrix4) &other);
+
   INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix4) &other);
   INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix4) &other);
   INLINE_LINMATH void transpose_in_place();
   INLINE_LINMATH void transpose_in_place();
 
 

+ 15 - 0
panda/src/linmath/lvecBase2_src.I

@@ -733,6 +733,21 @@ operator /= (FLOATTYPE scalar) {
 #endif
 #endif
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase2::componentwise_mult
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH void FLOATNAME(LVecBase2)::
+componentwise_mult(const FLOATNAME(LVecBase2) &other) {
+#ifdef HAVE_EIGEN
+  _v = _v.cwiseProduct(other._v);
+#else
+  _v(0) *= other._v(0);
+  _v(1) *= other._v(1);
+#endif  // HAVE_EIGEN
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase2::fmax
 //     Function: LVecBase2::fmax
 //       Access: Published
 //       Access: Published

+ 2 - 0
panda/src/linmath/lvecBase2_src.h

@@ -121,6 +121,8 @@ PUBLISHED:
   INLINE_LINMATH void operator *= (FLOATTYPE scalar);
   INLINE_LINMATH void operator *= (FLOATTYPE scalar);
   INLINE_LINMATH void operator /= (FLOATTYPE scalar);
   INLINE_LINMATH void operator /= (FLOATTYPE scalar);
 
 
+  INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase2) &other);
+
   EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase2) __pow__(FLOATTYPE exponent) const);
   EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase2) __pow__(FLOATTYPE exponent) const);
   EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
   EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
 
 

+ 16 - 0
panda/src/linmath/lvecBase3_src.I

@@ -909,6 +909,22 @@ operator /= (FLOATTYPE scalar) {
 #endif
 #endif
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase3::componentwise_mult
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH void FLOATNAME(LVecBase3)::
+componentwise_mult(const FLOATNAME(LVecBase3) &other) {
+#ifdef HAVE_EIGEN
+  _v = _v.cwiseProduct(other._v);
+#else
+  _v(0) *= other._v(0);
+  _v(1) *= other._v(1);
+  _v(2) *= other._v(2);
+#endif  // HAVE_EIGEN
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase3::fmax
 //     Function: LVecBase3::fmax
 //       Access: Public
 //       Access: Public

+ 2 - 0
panda/src/linmath/lvecBase3_src.h

@@ -134,6 +134,8 @@ PUBLISHED:
   INLINE_LINMATH void operator *= (FLOATTYPE scalar);
   INLINE_LINMATH void operator *= (FLOATTYPE scalar);
   INLINE_LINMATH void operator /= (FLOATTYPE scalar);
   INLINE_LINMATH void operator /= (FLOATTYPE scalar);
 
 
+  INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase3) &other);
+
   EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase3) __pow__(FLOATTYPE exponent) const);
   EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase3) __pow__(FLOATTYPE exponent) const);
   EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
   EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
 
 

+ 17 - 0
panda/src/linmath/lvecBase4_src.I

@@ -892,6 +892,23 @@ operator /= (FLOATTYPE scalar) {
 #endif
 #endif
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase4::componentwise_mult
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH void FLOATNAME(LVecBase4)::
+componentwise_mult(const FLOATNAME(LVecBase4) &other) {
+#ifdef HAVE_EIGEN
+  _v = _v.cwiseProduct(other._v);
+#else
+  _v(0) *= other._v(0);
+  _v(1) *= other._v(1);
+  _v(2) *= other._v(2);
+  _v(3) *= other._v(3);
+#endif  // HAVE_EIGEN
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase4::fmax
 //     Function: LVecBase4::fmax
 //       Access: Published
 //       Access: Published

+ 2 - 0
panda/src/linmath/lvecBase4_src.h

@@ -135,6 +135,8 @@ PUBLISHED:
   INLINE_LINMATH void operator *= (FLOATTYPE scalar);
   INLINE_LINMATH void operator *= (FLOATTYPE scalar);
   INLINE_LINMATH void operator /= (FLOATTYPE scalar);
   INLINE_LINMATH void operator /= (FLOATTYPE scalar);
 
 
+  INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase4) &other);
+
   EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase4) __pow__(FLOATTYPE exponent) const);
   EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase4) __pow__(FLOATTYPE exponent) const);
   EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
   EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));