29 #include <ossim/matrix/newmat.h>
30 #include <ossim/matrix/newmatap.h>
32 #include "WOSSIMHelper.h"
34 std::shared_ptr< NEWMAT::Matrix > WOSSIMHelper::OWMatrixToOSSIMMatrix(
const WMatrix<double> &input )
36 std::shared_ptr< NEWMAT::Matrix > result(
new NEWMAT::Matrix( input.
getNbRows(), input.
getNbCols() ) );
37 for(
size_t row = 0; row < input.
getNbRows(); row++ )
39 for(
size_t col = 0; col < input.
getNbCols(); col++ )
41 ( *result )(
static_cast<int>( row+1 ),
static_cast<int>( col+1 ) ) = input( row, col );
47 WMatrix<double> WOSSIMHelper::OSSIMMatrixToOWMatrix(
const NEWMAT::Matrix& input )
49 WMatrix<double> result(
static_cast<size_t>( input.Nrows() ),
static_cast<size_t>( input.Ncols() ) );
51 for(
size_t row = 0; row < result.getNbRows(); row++ )
53 for(
size_t col = 0; col < result.getNbCols(); col++ )
55 result( row, col ) = input(
static_cast<int>( row+1 ),
static_cast<int>( col+1 ) );
61 WMatrix<double> WOSSIMHelper::OSSIMDiagonalMatrixToOWMatrix(
const NEWMAT::DiagonalMatrix& input )
63 WMatrix<double> result(
static_cast<size_t>( input.Nrows() ),
static_cast<size_t>( input.Ncols() ) );
65 for(
size_t i = 0; i < result.getNbRows(); i++ )
67 result( i, i ) = input(
static_cast<int>( i+1 ) );
72 WValue<double> WOSSIMHelper::OSSIMDiagonalMatrixToOWVector(
const NEWMAT::DiagonalMatrix& input )
76 for(
size_t i = 0; i < result.size(); i++ )
78 result[ i ] = input(
static_cast<int>( i+1 ) );
98 std::shared_ptr< NEWMAT::Matrix > AA( OWMatrixToOSSIMMatrix( A ) );
99 NEWMAT::DiagonalMatrix SS(
static_cast<int>( S.
size() ) );
100 NEWMAT::Matrix UU(
static_cast<int>( U.
getNbRows() ),
static_cast<int>( U.
getNbCols() ) );
101 NEWMAT::Matrix VV(
static_cast<int>( V.
getNbRows() ),
static_cast<int>( V.
getNbCols() ) );
103 NEWMAT::SVD( *AA, SS, UU, VV );
105 S = OSSIMDiagonalMatrixToOWVector( SS );
106 U = OSSIMMatrixToOWMatrix( UU );
107 V = OSSIMMatrixToOWMatrix( VV );
size_t getNbRows() const
Get number of rows.
size_t getNbCols() const
Get number of columns.
Base class for all higher level values like tensors, vectors, matrices and so on.
size_t size() const
Get number of components the value consists of.