Fix std and zeros bug.
This commit is contained in:
@@ -127,17 +127,19 @@ Matrix Aurora::std(const Matrix &aMatrix) {
|
||||
Matrix src = aMatrix.isComplex() ? Aurora::abs(aMatrix) : aMatrix;
|
||||
int calc_size = src.getDimSize(0) == 1 ? src.getDimSize(1) : src.getDimSize(0);
|
||||
int col = src.getDimSize(0) == 1?1:src.getDimSize(1) ;
|
||||
double *temp = malloc(aMatrix.getDataSize(), aMatrix.getValueType()==Complex);
|
||||
cblas_dcopy(aMatrix.getDataSize() * aMatrix.getValueType(),aMatrix.getData(),1,temp,1);
|
||||
auto std = Aurora::malloc(col);
|
||||
for (int i = 0; i < col; ++i) {
|
||||
double *p = src.getData() + i * calc_size;
|
||||
double *p = temp + i * calc_size;
|
||||
double mean = cblas_dasum(calc_size, p, 1) / calc_size;
|
||||
vdSubI(calc_size, p, 1, &mean, 0, p, 1);
|
||||
vdSqr(calc_size, p, p);
|
||||
std[i] = cblas_dasum(calc_size, p, 1) / (calc_size - 1);
|
||||
}
|
||||
Aurora::free(temp);
|
||||
vdSqrt(src.getDimSize(1), std, std);
|
||||
return Matrix::New(std, 1, col, aMatrix.getDimSize(2));
|
||||
|
||||
}
|
||||
|
||||
Matrix Aurora::min(const Matrix &aMatrix, FunctionDirection direction, long& rowIdx, long& colIdx) {
|
||||
@@ -391,7 +393,7 @@ Matrix Aurora::mean(const Matrix &aMatrix, FunctionDirection direction, bool aIn
|
||||
case All:
|
||||
{
|
||||
Eigen::Map<Eigen::VectorXd> srcV(aMatrix.getData(),aMatrix.getDataSize());
|
||||
double * ret = malloc(1);
|
||||
double * ret = malloc(64);
|
||||
ret[0] = srcV.array().mean();
|
||||
return Matrix::New(ret,1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user