Fix polyval, add convertfp16toFloat
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <cstddef>
|
||||
#include <gtest/gtest.h>
|
||||
#include <vector>
|
||||
|
||||
#include "MatlabReader.h"
|
||||
#include "TestUtility.h"
|
||||
|
||||
#include "Matrix.h"
|
||||
@@ -107,14 +109,18 @@ TEST_F(Function1D_Test, interp1) {
|
||||
}
|
||||
|
||||
TEST_F(Function1D_Test, polyval){
|
||||
double *dataP = new double[3]{3,2,1};
|
||||
double *dataX = new double[3]{5,7,9};
|
||||
auto matrixP = Aurora::Matrix::fromRawData(dataP,3);
|
||||
auto matrixX = Aurora::Matrix::fromRawData(dataX,3);
|
||||
// double *dataP = new double[3]{3,2,1};
|
||||
double *dataP = new double[6]{2.78786e-9, -1.398845e-6, 3.287156e-4, -5.799136e-2, 5.038813, 1.402385e3};
|
||||
// double *dataX = new double[3]{5,7,9};
|
||||
double *dataX = new double[1]{24.570274572648690};
|
||||
|
||||
|
||||
auto matrixP = Aurora::Matrix::fromRawData(dataP,6);
|
||||
auto matrixX = Aurora::Matrix::fromRawData(dataX,1);
|
||||
auto result = Aurora::polyval(matrixP,matrixX);
|
||||
EXPECT_DOUBLE_EQ(86., result.getData()[0]);
|
||||
EXPECT_DOUBLE_EQ(162., result.getData()[1]);
|
||||
EXPECT_DOUBLE_EQ(262., result.getData()[2]);
|
||||
EXPECT_DOUBLE_EQ(1495.6, result.getData()[0]);
|
||||
// EXPECT_DOUBLE_EQ(162., result.getData()[1]);
|
||||
// EXPECT_DOUBLE_EQ(262., result.getData()[2]);
|
||||
}
|
||||
|
||||
TEST_F(Function1D_Test, complexAndEtc){
|
||||
@@ -501,3 +507,18 @@ TEST_F(Function1D_Test, padding) {
|
||||
auto result = ma.getData();
|
||||
|
||||
}
|
||||
|
||||
TEST_F(Function1D_Test, convertfp16tofloat) {
|
||||
MatlabReader m("/home/krad/TestData/convertReal.mat");
|
||||
|
||||
size_t count = 0;
|
||||
auto input = m.readint16("input",count);
|
||||
auto ma = Aurora::Matrix::copyFromRawData((double*)input.get(),count/4);
|
||||
auto resultM = Aurora::convertfp16tofloat(ma);
|
||||
auto result = resultM.getData();
|
||||
auto output = m.read("output");
|
||||
for (size_t i = 0; i<count; i++) {
|
||||
EXPECT_EQ(result[i], output.getData()[i])<<"index:"<<i<<",input:"<< ((short*)ma.getData())[i]<<",input2:"<<input.get()[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user