Speedups: Matrix mult. in Gaussian NoiseModel. Removed size check in operator* in Matrix.h - ublas does this check when in debug mode.
							parent
							
								
									e935f1745e
								
							
						
					
					
						commit
						5e15564525
					
				| 
						 | 
					@ -115,8 +115,9 @@ inline Vector operator*(const Vector & v, const Matrix& A) {
 | 
				
			||||||
 * overload * for matrix multiplication (as BOOST does not)
 | 
					 * overload * for matrix multiplication (as BOOST does not)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
inline Matrix operator*(const Matrix& A, const Matrix& B) {
 | 
					inline Matrix operator*(const Matrix& A, const Matrix& B) {
 | 
				
			||||||
  if (A.size2()!=B.size1()) throw std::invalid_argument(
 | 
					  // richard: boost already does this check in debug mode I think
 | 
				
			||||||
  		boost::str(boost::format("Matrix operator* : A.n(%d)!=B.m(%d)") % A.size2() % B.size1()));
 | 
					//  if (A.size2()!=B.size1()) throw std::invalid_argument(
 | 
				
			||||||
 | 
					//  		boost::str(boost::format("Matrix operator* : A.n(%d)!=B.m(%d)") % A.size2() % B.size1()));
 | 
				
			||||||
  return prod(A,B);
 | 
					  return prod(A,B);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,24 +47,26 @@ namespace gtsam {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// functional
 | 
							// functional
 | 
				
			||||||
		Matrix Gaussian::Whiten(const Matrix& H) const {
 | 
							Matrix Gaussian::Whiten(const Matrix& H) const {
 | 
				
			||||||
			size_t m = H.size1(), n = H.size2();
 | 
					//			size_t m = H.size1(), n = H.size2();
 | 
				
			||||||
			Matrix W(m, n);
 | 
					//			Matrix W(m, n);
 | 
				
			||||||
			for (int j = 0; j < n; j++) {
 | 
					//			for (int j = 0; j < n; j++) {
 | 
				
			||||||
				Vector wj = whiten(column(H, j));
 | 
					//				Vector wj = whiten(column(H, j));
 | 
				
			||||||
				for (int i = 0; i < m; i++)
 | 
					//				for (int i = 0; i < m; i++)
 | 
				
			||||||
					W(i, j) = wj(i);
 | 
					//					W(i, j) = wj(i);
 | 
				
			||||||
			}
 | 
					//			}
 | 
				
			||||||
			return W;
 | 
					//			return W;
 | 
				
			||||||
 | 
							  return sqrt_information_ * H;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// in place
 | 
							// in place
 | 
				
			||||||
		void Gaussian::WhitenInPlace(Matrix& H) const {
 | 
							void Gaussian::WhitenInPlace(Matrix& H) const {
 | 
				
			||||||
			size_t m = H.size1(), n = H.size2();
 | 
					//			size_t m = H.size1(), n = H.size2();
 | 
				
			||||||
			for (int j = 0; j < n; j++) {
 | 
					//			for (int j = 0; j < n; j++) {
 | 
				
			||||||
				Vector wj = whiten(column(H, j));
 | 
					//				Vector wj = whiten(column(H, j));
 | 
				
			||||||
				for (int i = 0; i < m; i++)
 | 
					//				for (int i = 0; i < m; i++)
 | 
				
			||||||
					H(i, j) = wj(i);
 | 
					//					H(i, j) = wj(i);
 | 
				
			||||||
			}
 | 
					//			}
 | 
				
			||||||
 | 
							  H = sqrt_information_ * H;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* ************************************************************************* */
 | 
							/* ************************************************************************* */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue