Add log and log's unittest.
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::log(const Matrix& aMatrix, int aBaseNum)
|
||||
{
|
||||
size_t size = aMatrix.getDataSize();
|
||||
double* data = Aurora::malloc(size);
|
||||
vdLn(size, aMatrix.getData(), data);
|
||||
if(aBaseNum != -1)
|
||||
{
|
||||
double baseNum = aBaseNum;
|
||||
double temp;
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
vdLn(1, &baseNum, &temp);
|
||||
data[i] /= temp;
|
||||
}
|
||||
}
|
||||
|
||||
return Aurora::Matrix(std::shared_ptr<double>(data,Aurora::free),std::vector<int>{aMatrix.getDimSize(0),aMatrix.getDimSize(1),aMatrix.getDimSize(2)});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user