@@ -91,6 +91,7 @@ ALGORITHM_PARAMETER_DEF( Inverse, LCurveText);
9191ALGORITHM_PARAMETER_DEF ( Inverse, regularizationSolutionSubcase);
9292ALGORITHM_PARAMETER_DEF ( Inverse, regularizationResidualSubcase);
9393
94+
9495TikhonovAlgoAbstractBase::TikhonovAlgoAbstractBase ()
9596{
9697 using namespace Parameters ;
@@ -208,7 +209,7 @@ AlgorithmOutput TikhonovAlgoAbstractBase::run(const AlgorithmInput & input) cons
208209
209210 // Alocate Variable
210211 DenseMatrix solution;
211- double lambda_sq = 0 ;
212+ double lambda = 0 ;
212213 double lambda_ = 0 ;
213214
214215 // check input MATRICES
@@ -224,6 +225,9 @@ AlgorithmOutput TikhonovAlgoAbstractBase::run(const AlgorithmInput & input) cons
224225 int regularizationResidualSubcase_ = get (Parameters::regularizationResidualSubcase).toInt ();
225226
226227 algoImpl = new SolveInverseProblemWithStandardTikhonovImpl ( *castMatrix::toDense (forwardMatrix_), *castMatrix::toDense (measuredData_), *castMatrix::toDense (sourceWeighting_), *castMatrix::toDense (sensorWeighting_), regularizationChoice_, regularizationSolutionSubcase_, regularizationResidualSubcase_);
228+
229+
230+
227231 }
228232 else if ( TikhonovImplementation_gotten == std::string (" TikhonovSVD" ) ){
229233
@@ -237,12 +241,15 @@ AlgorithmOutput TikhonovAlgoAbstractBase::run(const AlgorithmInput & input) cons
237241 auto singularValues_ = input.get <Matrix>(TikhonovAlgoAbstractBase::singularValues);
238242 auto matrixV_ = input.get <Matrix>(TikhonovAlgoAbstractBase::matrixV);
239243
244+
240245 // If there is a missing matrix from the precomputed SVD input
241246 if ( (matrixU_ == NULL ) || (singularValues_ == NULL ) || ( matrixV_ == NULL ) )
242247 algoImpl = new SolveInverseProblemWithTikhonovSVD_impl ( *castMatrix::toDense (forwardMatrix_), *castMatrix::toDense (measuredData_), *castMatrix::toDense (sourceWeighting_), *castMatrix::toDense (sensorWeighting_) );
243248 else
244249 algoImpl = new SolveInverseProblemWithTikhonovSVD_impl ( *castMatrix::toDense (forwardMatrix_), *castMatrix::toDense (measuredData_), *castMatrix::toDense (sourceWeighting_), *castMatrix::toDense (sensorWeighting_), *castMatrix::toDense (matrixU_), *castMatrix::toDense (singularValues_), *castMatrix::toDense (matrixV_) );
245250
251+
252+
246253 }
247254 else if ( TikhonovImplementation_gotten == std::string (" TikhonovTSVD" ) ){
248255
@@ -256,17 +263,23 @@ AlgorithmOutput TikhonovAlgoAbstractBase::run(const AlgorithmInput & input) cons
256263 auto singularValues_ = input.get <Matrix>(TikhonovAlgoAbstractBase::singularValues);
257264 auto matrixV_ = input.get <Matrix>(TikhonovAlgoAbstractBase::matrixV);
258265
266+
259267 // If there is a missing matrix from the precomputed SVD input
260268 if ( (matrixU_ == NULL ) || (singularValues_ == NULL ) || ( matrixV_ == NULL ) )
261269 algoImpl = new SolveInverseProblemWithTikhonovTSVD_impl ( *castMatrix::toDense (forwardMatrix_), *castMatrix::toDense (measuredData_), *castMatrix::toDense (sourceWeighting_), *castMatrix::toDense (sensorWeighting_) );
262270 else
263271 algoImpl = new SolveInverseProblemWithTikhonovTSVD_impl ( *castMatrix::toDense (forwardMatrix_), *castMatrix::toDense (measuredData_), *castMatrix::toDense (sourceWeighting_), *castMatrix::toDense (sensorWeighting_), *castMatrix::toDense (matrixU_), *castMatrix::toDense (singularValues_), *castMatrix::toDense (matrixV_) );
272+
273+
274+
264275 }
265276 else {
266277 THROW_ALGORITHM_PROCESSING_ERROR (" Not a valid Tikhonov Implementation selection" );
278+
267279 }
268280
269- // preAlocateInverseMatrices(forwardMatrix_,measuredData_,sourceWeighting_,sensorWeighting_);
281+
282+
270283
271284 // Get Regularization parameter(s) : Lambda
272285 if ((RegularizationMethod_gotten == " single" ) || (RegularizationMethod_gotten == " slider" ))
@@ -292,21 +305,12 @@ AlgorithmOutput TikhonovAlgoAbstractBase::run(const AlgorithmInput & input) cons
292305 }
293306
294307 std::cout << " Lambda: " << lambda_ << std::endl;
295- lambda_sq = lambda_ * lambda_;
308+ lambda = lambda_;
296309
297310
298- // compute inverse solution
299- solution = algoImpl->computeInverseSolution (lambda_sq , true );
311+ // compute final inverse solution
312+ solution = algoImpl->computeInverseSolution (lambda , true );
300313
301- //
302- // // set final result
303- // inverseSolution_.reset(new DenseMatrix(solution));
304-
305- // output regularization parameter
306- // DenseColumnMatrix tempLambda(1);
307- // tempLambda[0] = lambda_;
308- //
309- // regularizationParameter_. reset( new DenseColumnMatrix(tempLambda) );
310314
311315
312316 // Set outputs
@@ -337,7 +341,6 @@ double TikhonovAlgoAbstractBase::computeLcurve( const SCIRun::Core::Algorithms::
337341 const double lam_step = (log10 (lambdaMax_) - log10 (lambdaMin_)) / (nLambda-1 );
338342 std::cout << " Lambda power step: " << lam_step << " . Number: " << nLambda <<" . Lambda min: " << lambdaMin_ << " . Lambda max: " << lambdaMax_<< " . Ratio: " << lambdaMax_ / lambdaMin_ << std::endl;
339343 double lambda = 0 ;
340- double lambda_sq;
341344
342345 // prealocate vector of lambdas and eta and rho
343346 std::vector<double > lambdaArray (nLambda, 0.0 );
@@ -357,11 +360,8 @@ double TikhonovAlgoAbstractBase::computeLcurve( const SCIRun::Core::Algorithms::
357360 lambdaArray[j] = lambdaArray[j-1 ] * pow (10.0 ,lam_step);
358361 }
359362
360- // set current lambda
361- lambda_sq = lambdaArray[j] * lambdaArray[j];
362-
363363 // COMPUTE INVERSE SOLUTION
364- solution = algoImpl->computeInverseSolution ( lambda_sq , false );
364+ solution = algoImpl->computeInverseSolution ( lambdaArray[j] , false );
365365
366366
367367 // if using source regularization matrix, apply it to compute Rx (for the eta computations)
0 commit comments