v2.0.0
Loading...
Searching...
No Matches
sphara.cpp
Go to the documentation of this file.
1//=============================================================================================================
12
13//=============================================================================================================
14// INCLUDES
15//=============================================================================================================
16
17#include "sphara.h"
18
19//=============================================================================================================
20// QT INCLUDES
21//=============================================================================================================
22
23#include <QDebug>
24
25//=============================================================================================================
26// USED NAMESPACES
27//=============================================================================================================
28
29using namespace UTILSLIB;
30using namespace Eigen;
31
32//=============================================================================================================
33// DEFINE GLOBAL UTILSLIB METHODS
34//=============================================================================================================
35
36MatrixXd UTILSLIB::makeSpharaProjector(const MatrixXd& matBaseFct,
37 const VectorXi& vecIndices,
38 int iOperatorDim,
39 int iNBaseFct,
40 int iSkip)
41{
42 MatrixXd matSpharaOperator = MatrixXd::Identity(iOperatorDim, iOperatorDim);
43
44 if(matBaseFct.size() == 0) {
45 qWarning()<<"[UTILSLIB::makeSpharaProjector] Basis function matrix was empty. Returning identity matrix instead.";
46 return matSpharaOperator;
47 }
48
49 //Remove unwanted base functions
50 MatrixXd matSpharaGradCut = matBaseFct.block(0,0,matBaseFct.rows(),iNBaseFct);
51 MatrixXd matSpharaMultGrad = matSpharaGradCut * matSpharaGradCut.transpose().eval();
52
53 //Create the SPHARA operator
54 int rowIndex = 0;
55 int colIndex = 0;
56
57 for(int i = 0; i<=iSkip; i++) {
58 for(int r = i; r<vecIndices.rows(); r+=1+iSkip) {
59 for(int c = i; c<vecIndices.rows(); c+=1+iSkip) {
60 if((r < vecIndices.rows() || c < vecIndices.rows()) && (rowIndex < matSpharaMultGrad.rows() || colIndex < matSpharaMultGrad.cols())) {
61 matSpharaOperator(vecIndices(r),vecIndices(c)) = matSpharaMultGrad(rowIndex,colIndex);
62 } else {
63 qWarning()<<"UTILSLIB::makeSpharaProjector - Index is out of range. Returning identity matrix.";
64 //matSpharaOperator.setZero();
65 matSpharaOperator = MatrixXd::Identity(iOperatorDim, iOperatorDim);
66 return matSpharaOperator;
67 }
68
69 ++colIndex;
70 }
71
72 colIndex = 0;
73 ++rowIndex;
74 }
75
76 rowIndex = 0;
77 }
78
79 return matSpharaOperator;
80}
81
SPatial HARmonic Analysis (SPHARA) spatial-filter projector assembly.
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
DSPSHARED_EXPORT Eigen::MatrixXd makeSpharaProjector(const Eigen::MatrixXd &matBaseFct, const Eigen::VectorXi &vecIndices, int iOperatorDim, int iNBaseFct, int iSkip=0)