Add acos and acos's unittest.
This commit is contained in:
@@ -328,9 +328,9 @@ Matrix Aurora::log(const Matrix& aMatrix, int aBaseNum)
|
|||||||
{
|
{
|
||||||
double baseNum = aBaseNum;
|
double baseNum = aBaseNum;
|
||||||
double temp;
|
double temp;
|
||||||
|
vdLn(1, &baseNum, &temp);
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
vdLn(1, &baseNum, &temp);
|
|
||||||
data[i] /= temp;
|
data[i] /= temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,3 +371,17 @@ Matrix Aurora::mod(const Matrix& aMatrix, double aValue)
|
|||||||
|
|
||||||
return Matrix::New(resultData, aMatrix);
|
return Matrix::New(resultData, aMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix Aurora::acos(const Matrix& aMatrix)
|
||||||
|
{
|
||||||
|
if(aMatrix.isComplex() || aMatrix.isNull())
|
||||||
|
{
|
||||||
|
return Matrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size = aMatrix.getDataSize();
|
||||||
|
double* matrixData = aMatrix.getData();
|
||||||
|
double* resultData = Aurora::malloc(size);
|
||||||
|
vdAcos(size, matrixData, resultData);
|
||||||
|
return Matrix::New(resultData, aMatrix);
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ namespace Aurora {
|
|||||||
|
|
||||||
Matrix mod(const Matrix& aMatrix, double aValue);
|
Matrix mod(const Matrix& aMatrix, double aValue);
|
||||||
|
|
||||||
|
Matrix acos(const Matrix& aMatrix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多项式计算
|
* 多项式计算
|
||||||
* @brief 例如p[1 0 1],x[3 2 5],代表对多项式 y = x^2 + 1 求(x=3, x=2, x=5)时所有的y
|
* @brief 例如p[1 0 1],x[3 2 5],代表对多项式 y = x^2 + 1 求(x=3, x=2, x=5)时所有的y
|
||||||
|
|||||||
@@ -246,3 +246,12 @@ TEST_F(Function1D_Test, mod) {
|
|||||||
EXPECT_DOUBLE_AE(result.getData()[1],0.83);
|
EXPECT_DOUBLE_AE(result.getData()[1],0.83);
|
||||||
EXPECT_DOUBLE_AE(result.getData()[2],0.4);
|
EXPECT_DOUBLE_AE(result.getData()[2],0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(Function1D_Test, acos) {
|
||||||
|
double *data = new double[3]{0.02,0.83,0.4,};
|
||||||
|
auto matrix = Aurora::Matrix::fromRawData(data, 3);
|
||||||
|
auto result = Aurora::acos(matrix);
|
||||||
|
EXPECT_DOUBLE_AE(result.getData()[0],1.5508);
|
||||||
|
EXPECT_DOUBLE_AE(result.getData()[1],0.5917);
|
||||||
|
EXPECT_DOUBLE_AE(result.getData()[2],1.1593);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user