Add size function
This commit is contained in:
@@ -88,3 +88,32 @@ Matrix Aurora::zeros(int aRow, int aColumn, int aSlice) {
|
|||||||
Matrix Aurora::zeros(int aSquareRow) {
|
Matrix Aurora::zeros(int aSquareRow) {
|
||||||
return Aurora::zeros(aSquareRow, aSquareRow);
|
return Aurora::zeros(aSquareRow, aSquareRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix Aurora::size(const Matrix &aMatrix)
|
||||||
|
{
|
||||||
|
if (aMatrix.isScalar()){
|
||||||
|
double * output = Aurora::malloc(1);
|
||||||
|
output[0]=1;
|
||||||
|
return Matrix::New(output,1,1,1);
|
||||||
|
}
|
||||||
|
else if (aMatrix.isVector()){
|
||||||
|
double * output = Aurora::malloc(1);
|
||||||
|
output[0]=aMatrix.getDataSize();
|
||||||
|
return Matrix::New(output,1,1,1);
|
||||||
|
}
|
||||||
|
//3D
|
||||||
|
else if (aMatrix.getDimSize(2)>1){
|
||||||
|
double * output = Aurora::malloc(3);
|
||||||
|
output[0]=aMatrix.getDimSize(0);
|
||||||
|
output[1]=aMatrix.getDimSize(1);
|
||||||
|
output[2]=aMatrix.getDimSize(2);
|
||||||
|
return Matrix::New(output,3,1,1);
|
||||||
|
}
|
||||||
|
//2D matrix
|
||||||
|
else{
|
||||||
|
double * output = Aurora::malloc(2);
|
||||||
|
output[0]=aMatrix.getDimSize(0);
|
||||||
|
output[1]=aMatrix.getDimSize(1);
|
||||||
|
return Matrix::New(output,2,1,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace Aurora {
|
|||||||
Matrix interp3(const Matrix& aX, const Matrix& aY, const Matrix& aZ, const Matrix& aV, const Matrix& aX1, const Matrix& aY1, const Matrix& aZ1,InterpnMethod aMethod);
|
Matrix interp3(const Matrix& aX, const Matrix& aY, const Matrix& aZ, const Matrix& aV, const Matrix& aX1, const Matrix& aY1, const Matrix& aZ1,InterpnMethod aMethod);
|
||||||
Matrix interpn(const Matrix& aX, const Matrix& aY, const Matrix& aZ, const Matrix& aV, const Matrix& aX1, const Matrix& aY1, const Matrix& aZ1,InterpnMethod aMethod);
|
Matrix interpn(const Matrix& aX, const Matrix& aY, const Matrix& aZ, const Matrix& aV, const Matrix& aX1, const Matrix& aY1, const Matrix& aZ1,InterpnMethod aMethod);
|
||||||
|
|
||||||
|
Matrix size(const Matrix &aMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user