diff --git a/src/Function1D.cpp b/src/Function1D.cpp index 1fb6a5c..717edeb 100644 --- a/src/Function1D.cpp +++ b/src/Function1D.cpp @@ -1,4 +1,5 @@ #include "Function1D.h" +#include "Function2D.h" #include "Function.h" //必须在Eigen之前 @@ -420,12 +421,16 @@ Matrix Aurora::conj(const Matrix& aMatrix) double Aurora::norm(const Matrix& aMatrix, NormMethod aNormMethod) { - if(aMatrix.isComplex() || aMatrix.isNull()) + if(aMatrix.isNull()) { return NAN; } size_t size = aMatrix.getDataSize(); + if(aMatrix.isComplex()) + { + size*=2; + } int column = aMatrix.getDimSize(1); int row = aMatrix.getDimSize(0); if (aNormMethod == NormMethod::Norm1) @@ -433,7 +438,7 @@ double Aurora::norm(const Matrix& aMatrix, NormMethod aNormMethod) double value = 0; for(int i=0; i value) { value = temp; @@ -450,9 +455,18 @@ double Aurora::norm(const Matrix& aMatrix, NormMethod aNormMethod) //columns > 1 if(aMatrix.getDimSize(1) > 1) { - Eigen::Map eMatrix(aMatrix.getData(),aMatrix.getDimSize(0),aMatrix.getDimSize(1)); - Eigen::JacobiSVD svd(eMatrix, Eigen::ComputeThinU | Eigen::ComputeThinV); - return svd.singularValues()(0); + if(aMatrix.isComplex()) + { + Eigen::Map eMatrix((MKL_Complex16*)aMatrix.getData(), row, column); + Eigen::JacobiSVD svd(eMatrix, Eigen::ComputeThinU | Eigen::ComputeThinV); + return svd.singularValues()(0); + } + else + { + Eigen::Map eMatrix(aMatrix.getData(), row, column); + Eigen::JacobiSVD svd(eMatrix, Eigen::ComputeThinU | Eigen::ComputeThinV); + return svd.singularValues()(0); + } } else { @@ -507,3 +521,20 @@ Matrix Aurora::horzcat(const Matrix& aMatrix1, const Matrix& aMatrix2) return Matrix::New(resultData, row, column1+column2, 1, aMatrix1.getValueType()); } + +Matrix Aurora::vecnorm(const Matrix& aMatrix, NormMethod aNormMethod, int aDim) +{ + //only surpport aDim = 1 for now. + if(aDim != 1 || aNormMethod == NormMethod::NormF || aMatrix.isNull()) + { + return Matrix(); + } + int column = aMatrix.getDimSize(1); + double* resultData = Aurora::malloc(column); + for(int i=0; i