PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
PlusMath.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2  Program: Plus
3  Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4  See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #ifndef __PLUSMATH_H
8 #define __PLUSMATH_H
9 
10 #include "PlusConfigure.h"
11 #include "vtkPlusCommonExport.h"
12 
13 #include <vector>
14 
15 #include "vnl/vnl_matrix_fixed.h"
16 #include "vnl/vnl_vector.h"
17 #include "vnl/vnl_sparse_matrix.h"
18 #include "vtkMath.h"
19 
20 #include <igsioMath.h>
21 
22 class vtkMatrix4x4;
23 class vtkTransform;
24 
25 #if _MSC_VER == 1600 // VS 2010
26 namespace std
27 {
28  double vtkPlusCommonExport round(double arg);
29 }
30 #endif
31 
37 class vtkPlusCommonExport PlusMath
38 {
39 public:
40 
50  static PlusStatus LSQRMinimize(const std::vector< std::vector<double> > &aMatrix, const std::vector<double> &bVector, vnl_vector<double> &resultVector, double* mean = NULL, double* stdev = NULL, vnl_vector<unsigned int>* notOutliersIndices=NULL);
60  static PlusStatus LSQRMinimize(const std::vector<vnl_vector<double> > &aMatrix, const std::vector<double> &bVector, vnl_vector<double> &resultVector, double* mean = NULL, double* stdev = NULL , vnl_vector<unsigned int>* notOutliersIndices=NULL);
69  static PlusStatus LSQRMinimize(const vnl_sparse_matrix<double> &sparseMatrixLeftSide, const vnl_vector<double> &vectorRightSide, vnl_vector<double> &resultVector, double* mean = NULL, double* stdev = NULL, vnl_vector<unsigned int>* notOutliersIndices=NULL);
70 
72  static void ConvertVnlMatrixToVtkMatrix(const vnl_matrix_fixed<double,4,4>& inVnlMatrix, vtkMatrix4x4* outVtkMatrix);
73  static void ConvertVtkMatrixToVnlMatrix(const vtkMatrix4x4* inVtkMatrix, vnl_matrix_fixed<double,4,4>& outVnlMatrix );
74 
75 
77  static void PrintMatrix(vnl_matrix_fixed<double,4,4> matrix, std::ostringstream &stream, int precision = 3);
78 
80  static void LogMatrix(const vnl_matrix_fixed<double,4,4>& matrix, int precision = 3);
81 
82 protected:
83  PlusMath();
84  ~PlusMath();
85 
87  static PlusStatus RemoveOutliersFromLSQR(
88  vnl_sparse_matrix<double> &sparseMatrixLeftSide,
89  vnl_vector<double> &vectorRightSide,
90  vnl_vector<double> &resultVector,
91  bool &outlierFound,
92  double thresholdMultiplier = 3.0,
93  double* mean = NULL,
94  double* stdev = NULL,
95  vnl_vector<unsigned int>* nonOutlierIndices = NULL
96  );
97 
98 private:
99  PlusMath(PlusMath const&);
100  PlusMath& operator=(PlusMath const&);
101 };
102 
103 #endif
igsioStatus PlusStatus
Definition: PlusCommon.h:40
A utility class that contains static functions for various useful commonly used computations.
Definition: PlusMath.h:37