Add floor to Function1D.

This commit is contained in:
kradchen
2023-05-18 16:52:03 +08:00
parent a1e359231e
commit bb56a89f8f
2 changed files with 25 additions and 0 deletions

View File

@@ -201,6 +201,27 @@ Aurora::Matrix Aurora::round(const Aurora::Matrix &&matrix) {
return matrix;
}
Aurora::Matrix Aurora::floor(const Aurora::Matrix &matrix) {
auto output = malloc(matrix.getDataSize());
//for real part
vdRoundI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, output, SAME_STRIDE);
if (matrix.getValueType() == Complex) {
//for imag part
vdFloorI(matrix.getDataSize(), matrix.getData() + 1, SAME_STRIDE, output + 1, SAME_STRIDE);
}
return Aurora::Matrix::New(output, matrix);
}
Aurora::Matrix Aurora::floor(const Aurora::Matrix &&matrix) {
//for real part
vdRoundI(matrix.getDataSize(), matrix.getData(), SAME_STRIDE, matrix.getData(), SAME_STRIDE);
if (matrix.getValueType() == Complex) {
//for imag part
vdFloorI(matrix.getDataSize(), matrix.getData() + 1, SAME_STRIDE, matrix.getData() + 1, SAME_STRIDE);
}
return matrix;
}
Matrix Aurora::auroraNot(const Matrix& aMatrix){
return auroraNot(std::forward<Matrix&&>(aMatrix.deepCopy()));
}

View File

@@ -30,6 +30,10 @@ namespace Aurora {
Matrix round(const Matrix&& matrix);
Matrix floor(const Matrix& matrix);
Matrix floor(const Matrix&& matrix);
/**
* 开根号,暂时只支持正整数
* @param matrix