Add zeros and ones to Function3D.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include <iostream>
|
||||
#include "Function3D.h"
|
||||
#include "Function2D.h"
|
||||
#include "Function.h"
|
||||
|
||||
#include "mkl.h"
|
||||
|
||||
using namespace Aurora;
|
||||
|
||||
Matrix Aurora::interp3(const Matrix& aX, const Matrix& aY, const Matrix& aZ, const Matrix& aV, const Matrix& aX1, const Matrix& aY1, const Matrix& aZ1,InterpnMethod aMethod)
|
||||
@@ -44,3 +47,43 @@ Matrix Aurora::interpn(const Matrix& aX, const Matrix& aY, const Matrix& aZ, con
|
||||
{
|
||||
return Aurora::interp3(aY,aX,aZ,aV,aY1,aX1,aZ1,aMethod);
|
||||
}
|
||||
|
||||
Matrix Aurora::ones(int aRow, int aColumn, int aSlice) {
|
||||
if (aRow == 0 || aColumn == 0)
|
||||
{
|
||||
std::cerr<<"ones function can create matrix with dim unit cont =0";
|
||||
return Matrix();
|
||||
}
|
||||
int rowSize = aRow;
|
||||
int colSize = aColumn;
|
||||
int sliceSize = aSlice == 0 ? 1 : aSlice;
|
||||
size_t arraySize = rowSize * colSize* sliceSize;
|
||||
double* data = malloc(arraySize);
|
||||
double one = 1.0;
|
||||
cblas_dcopy(arraySize,&one,0,data,1);
|
||||
return Matrix::New(data,rowSize,colSize,aSlice);
|
||||
}
|
||||
|
||||
Matrix Aurora::ones(int aSquareRow) {
|
||||
return Aurora::ones(aSquareRow, aSquareRow);
|
||||
}
|
||||
|
||||
Matrix Aurora::zeros(int aRow, int aColumn, int aSlice) {
|
||||
if (aRow == 0 || aColumn == 0)
|
||||
{
|
||||
std::cerr<<"zeros function can create matrix with dim unit cont =0";
|
||||
return Matrix();
|
||||
}
|
||||
int rowSize = aRow;
|
||||
int colSize = aColumn;
|
||||
int sliceSize = aSlice == 0 ? 1 : aSlice;
|
||||
size_t arraySize = rowSize * colSize* sliceSize;
|
||||
double* data = malloc(arraySize);
|
||||
double zero = 0.0;
|
||||
cblas_dcopy(arraySize,&zero,0,data,1);
|
||||
return Matrix::New(data,rowSize,colSize,aSlice);
|
||||
}
|
||||
|
||||
Matrix Aurora::zeros(int aSquareRow) {
|
||||
return Aurora::zeros(aSquareRow, aSquareRow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user