Function1D bug fix and unit test.
This commit is contained in:
@@ -26,7 +26,7 @@ Aurora::Matrix Aurora::complex(const Aurora::Matrix &matrix) {
|
||||
std::cerr<<"complex not support complex value type"<<std::endl;
|
||||
return matrix;
|
||||
}
|
||||
auto output = (std::complex<double> *) mkl_malloc(matrix.getDataSize() * sizeof(std::complex<double>), 64);
|
||||
auto output = malloc(matrix.getDataSize() ,true);
|
||||
memset(output, 0, (matrix.getDataSize() * sizeof(std::complex<double>)));
|
||||
cblas_dcopy(matrix.getDataSize(), matrix.getData(), REAL_STRIDE, (double *) output, COMPLEX_STRIDE);
|
||||
return Aurora::Matrix::New((double *) output, matrix.getDimSize(0), matrix.getDimSize(1), matrix.getDimSize(2),
|
||||
@@ -38,7 +38,7 @@ Aurora::Matrix Aurora::real(const Aurora::Matrix &matrix) {
|
||||
std::cerr<<"real only support complex value type"<<std::endl;
|
||||
return matrix;
|
||||
}
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = (double *) malloc(matrix.getDataSize());
|
||||
memset(output, 0, (matrix.getDataSize() * sizeof(double)));
|
||||
cblas_dcopy(matrix.getDataSize(), matrix.getData(),COMPLEX_STRIDE , (double *) output, REAL_STRIDE);
|
||||
return Aurora::Matrix::New((double *) output, matrix.getDimSize(0), matrix.getDimSize(1), matrix.getDimSize(2));
|
||||
@@ -49,14 +49,14 @@ Aurora::Matrix Aurora::imag(const Aurora::Matrix &matrix) {
|
||||
std::cerr<<"imag only support complex value type"<<std::endl;
|
||||
return matrix;
|
||||
}
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = malloc(matrix.getDataSize());
|
||||
memset(output, 0, (matrix.getDataSize() * sizeof(double)));
|
||||
cblas_dcopy(matrix.getDataSize(), matrix.getData()+1,COMPLEX_STRIDE , (double *) output, REAL_STRIDE);
|
||||
return Aurora::Matrix::New((double *) output, matrix.getDimSize(0), matrix.getDimSize(1), matrix.getDimSize(2));
|
||||
}
|
||||
|
||||
Aurora::Matrix Aurora::ceil(const Aurora::Matrix &matrix) {
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = malloc(matrix.getDataSize());
|
||||
//for real part
|
||||
vdCeilI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, output, SAME_STRIDE);
|
||||
if (matrix.getValueType() == Complex) {
|
||||
@@ -78,7 +78,7 @@ Aurora::Matrix Aurora::ceil(const Aurora::Matrix &&matrix) {
|
||||
}
|
||||
|
||||
Aurora::Matrix Aurora::round(const Aurora::Matrix &matrix) {
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = malloc(matrix.getDataSize());
|
||||
//for real part
|
||||
vdRoundI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, output, SAME_STRIDE);
|
||||
if (matrix.getValueType() == Complex) {
|
||||
@@ -102,7 +102,7 @@ Aurora::Matrix Aurora::round(const Aurora::Matrix &&matrix) {
|
||||
Aurora::Matrix Aurora::sqrt(const Aurora::Matrix& matrix) {
|
||||
|
||||
if (matrix.getValueType() != Complex) {
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = malloc(matrix.getDataSize());
|
||||
vdSqrtI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, output, SAME_STRIDE);
|
||||
return Aurora::Matrix::New(output, matrix);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ Aurora::Matrix Aurora::sqrt(const Aurora::Matrix& matrix) {
|
||||
return Aurora::Matrix();
|
||||
}
|
||||
|
||||
Aurora::Matrix Aurora::sqrt(const Aurora::Matrix&& matrix) {
|
||||
Aurora::Matrix Aurora::sqrt(Aurora::Matrix&& matrix) {
|
||||
std::cout<<"RR sqrt"<<std::endl;
|
||||
if (matrix.getValueType() != Complex) {
|
||||
vdSqrtI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, matrix.getData(), SAME_STRIDE);
|
||||
@@ -121,7 +121,7 @@ Aurora::Matrix Aurora::sqrt(const Aurora::Matrix&& matrix) {
|
||||
}
|
||||
|
||||
Aurora::Matrix Aurora::abs(const Aurora::Matrix &matrix) {
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = malloc(matrix.getDataSize());
|
||||
if (matrix.getValueType()==Normal){
|
||||
vdAbsI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, output, SAME_STRIDE);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ Aurora::Matrix Aurora::abs(const Aurora::Matrix &matrix) {
|
||||
return Aurora::Matrix::New(output, matrix);
|
||||
}
|
||||
|
||||
Aurora::Matrix Aurora::abs(const Aurora::Matrix&& matrix) {
|
||||
Aurora::Matrix Aurora::abs(Aurora::Matrix&& matrix) {
|
||||
std::cout<<"RR abs"<<std::endl;
|
||||
if (matrix.getValueType()==Normal){
|
||||
vdAbsI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, matrix.getData(), SAME_STRIDE);
|
||||
@@ -139,7 +139,7 @@ Aurora::Matrix Aurora::abs(const Aurora::Matrix&& matrix) {
|
||||
}
|
||||
//TODO:考虑尝试是不是使用realloc缩短已分配的内存的方式重用matrix
|
||||
else{
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(double), 64);
|
||||
auto output = malloc(matrix.getDataSize());
|
||||
vzAbsI(matrix.getDataSize(), (std::complex<double> *)matrix.getData(), SAME_STRIDE,output, SAME_STRIDE);
|
||||
return Aurora::Matrix::New(output, matrix);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ Aurora::Matrix Aurora::sign(const Aurora::Matrix &matrix) {
|
||||
}
|
||||
else{
|
||||
//sign(x) = x./abs(x),前提是 x 为复数。
|
||||
auto output = (double *) mkl_malloc(matrix.getDataSize() * sizeof(std::complex<double>), 64);
|
||||
auto output = malloc(matrix.getDataSize(),true);
|
||||
Matrix absMatrix = abs(matrix);
|
||||
vdDivI(matrix.getDataSize(), matrix.getData(),COMPLEX_STRIDE,
|
||||
absMatrix.getData(), REAL_STRIDE,output,COMPLEX_STRIDE);
|
||||
@@ -165,7 +165,7 @@ Aurora::Matrix Aurora::sign(const Aurora::Matrix &matrix) {
|
||||
}
|
||||
}
|
||||
|
||||
Aurora::Matrix Aurora::sign(const Aurora::Matrix&& matrix) {
|
||||
Aurora::Matrix Aurora::sign(Aurora::Matrix&& matrix) {
|
||||
std::cout<<"RR sign"<<std::endl;
|
||||
if (matrix.getValueType()==Normal){
|
||||
Eigen::Map<Eigen::VectorXd> retV(matrix.getData(),matrix.getDataSize());
|
||||
|
||||
@@ -31,15 +31,15 @@ namespace Aurora {
|
||||
*/
|
||||
Matrix sqrt(const Matrix& matrix);
|
||||
|
||||
Matrix sqrt(const Matrix&& matrix);
|
||||
Matrix sqrt(Matrix&& matrix);
|
||||
|
||||
Matrix abs(const Matrix& matrix);
|
||||
|
||||
Matrix abs(const Matrix&& matrix);
|
||||
Matrix abs(Matrix&& matrix);
|
||||
|
||||
Matrix sign(const Matrix& matrix);
|
||||
|
||||
Matrix sign(const Matrix&& matrix);
|
||||
Matrix sign(Matrix&& matrix);
|
||||
|
||||
Matrix interp1(const Matrix& aX, const Matrix& aV, const Matrix& aX1, InterpnMethod aMethod);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user