Add polyval to Function1D
This commit is contained in:
@@ -303,3 +303,22 @@ Matrix Aurora::repmat(const Matrix& aMatrix,int aRowTimes, int aColumnTimes, int
|
||||
|
||||
return Matrix(std::shared_ptr<double>(resultData, Aurora::free), resultInfo, aMatrix.getValueType());
|
||||
}
|
||||
|
||||
|
||||
Matrix Aurora::polyval(const Matrix &aP, const Matrix &aX) {
|
||||
auto result = malloc(aX.getDataSize());
|
||||
auto powArg = new double[aP.getDataSize()];
|
||||
for (int j = aP.getDataSize(), i = 0; j > 0; --j, ++i) {
|
||||
powArg[i] = (double) (j - 1);
|
||||
}
|
||||
auto temp = new double[aP.getDataSize()];
|
||||
for (int i = 0; i < aX.getDataSize(); ++i) {
|
||||
vdPowI(aP.getDataSize(), aX.getData() + i, 0, powArg, 1, temp, 1);
|
||||
vdMul(aP.getDataSize(), aP.getData(), temp, temp);
|
||||
result[i] = cblas_dasum(3, temp, 1);
|
||||
}
|
||||
delete[] powArg;
|
||||
delete[] temp;
|
||||
|
||||
return Matrix::New(result,aX);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user