@@ -70,21 +70,32 @@ using namespace SCIRun::Core::Algorithms::Inverse;
7070void SolveInverseProblemWithTikhonovSVD_impl::preAlocateInverseMatrices (const SCIRun::Core::Datatypes::DenseMatrix& forwardMatrix_, const SCIRun::Core::Datatypes::DenseMatrix& measuredData_ , const SCIRun::Core::Datatypes::DenseMatrix& sourceWeighting_, const SCIRun::Core::Datatypes::DenseMatrix& sensorWeighting_, const SCIRun::Core::Datatypes::DenseMatrix& matrixU_, const SCIRun::Core::Datatypes::DenseMatrix& singularValues_, const SCIRun::Core::Datatypes::DenseMatrix& matrixV_)
7171{
7272
73- // if (!matrixU_.size())&&(!matrixV_.size())&&(!singularValues_.size()){
74- // std::cout << "Precomputed SVD variables found as an input" << std::endl;
75- //
76- // svd_MatrixU = *matrixU_;
77- // svd_MatrixV = *matrixV_;
78- // svd_SingularValues = *singularValues_;
79- //
80- // }else{
73+ // alocate U and V matrices
74+ svd_MatrixU = matrixU_;
75+ svd_MatrixV = matrixV_;
76+
77+ // alocate singular values
78+ if (singularValues_.ncols () == 1 ){
79+ svd_SingularValues = singularValues_;
80+ }
81+ else {
82+ svd_SingularValues = singularValues_.diagonal ();
83+ }
84+
85+ // Compute the projection of data y on the left singular vectors
86+ Uy = svd_MatrixU.transpose () * (measuredData_);
87+
88+ // determine rank
89+ rank = svd_SingularValues.nrows ();
90+ }
8191
82- std::cout << " No precomputed SVD... computing now" << std::endl;
92+ void SolveInverseProblemWithTikhonovSVD_impl::preAlocateInverseMatrices (const SCIRun::Core::Datatypes::DenseMatrix& forwardMatrix_, const SCIRun::Core::Datatypes::DenseMatrix& measuredData_ , const SCIRun::Core::Datatypes::DenseMatrix& sourceWeighting_, const SCIRun::Core::Datatypes::DenseMatrix& sensorWeighting_)
93+ {
8394
8495 // Compute the SVD of the forward matrix
8596 Eigen::JacobiSVD<SCIRun::Core::Datatypes::DenseMatrix::EigenBase> SVDdecomposition ( forwardMatrix_, Eigen::ComputeFullU | Eigen::ComputeFullV);
8697
87- // alocate the left and right singular vectors and the singular values
98+ // alocate the left and right singular vectors and the singular values
8899 svd_MatrixU = SVDdecomposition.matrixU ();
89100 svd_MatrixV = SVDdecomposition.matrixV ();
90101 svd_SingularValues = SVDdecomposition.singularValues ();
@@ -93,11 +104,7 @@ void SolveInverseProblemWithTikhonovSVD_impl::preAlocateInverseMatrices(const SC
93104 rank = SVDdecomposition.nonzeroSingularValues ();
94105
95106 // Compute the projection of data y on the left singular vectors
96- auto tempUy = SVDdecomposition.matrixU ().transpose () * (measuredData_);
97-
98- Uy = tempUy;
99-
100- // }
107+ Uy = svd_MatrixU.transpose () * (measuredData_);
101108}
102109
103110// ////////////////////////////////////////////////////////////////////
0 commit comments