Add log and log's unittest.
This commit is contained in:
@@ -144,7 +144,7 @@ namespace Aurora {
|
||||
return result;
|
||||
}
|
||||
|
||||
double *malloc(int size, bool complex) {
|
||||
double *malloc(size_t size, bool complex) {
|
||||
if (!complex) return (double *) mkl_malloc(size * sizeof(double), 64);
|
||||
return (double *) mkl_malloc(size * sizeof(std::complex<double>), 64);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <complex>
|
||||
|
||||
namespace Aurora{
|
||||
double* malloc(int size,bool complex = false);
|
||||
double* malloc(size_t size,bool complex = false);
|
||||
void free(void* ptr);
|
||||
double* mul( double scalar, double * input, int size);
|
||||
double* mul( double* inputA, double * inputB, int size);
|
||||
|
||||
@@ -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