Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python_numpy/python_numpy_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ inline auto operator*(const Matrix<DefSparse, T, M, N, SparseAvailable_A> &A,
std::move(A.matrix * B.matrix));
}

/* Type */
template <typename A_Type, typename B_Type>
using A_Multiply_B_Type =
decltype(std::declval<A_Type>() * std::declval<B_Type>());

template <typename A_Type>
using Transpose_Type = decltype(std::declval<A_Type>().transpose());

/* Matrix Type Checker */
template <typename MatrixInput>
using Is_Dense_Matrix =
Expand Down
4 changes: 2 additions & 2 deletions python_numpy/python_numpy_linalg_eig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,12 @@ class LinalgSolverEigSparse {
}

/* Set */
inline void set_iteration_max(std::size_t iteration_max) {
inline void set_iteration_max(const std::size_t &iteration_max) {
this->_Eigen_solver.iteration_max = iteration_max;
}

inline void set_iteration_max_for_eigen_vector(
std::size_t iteration_max_for_eigen_vector) {
const std::size_t &iteration_max_for_eigen_vector) {
this->_Eigen_solver.iteration_max_for_eigen_vector =
iteration_max_for_eigen_vector;
}
Expand Down
15 changes: 8 additions & 7 deletions python_numpy/python_numpy_linalg_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ class LinalgSolver {
return Matrix<DefDense, T, M, K>(this->X_1);
}

inline void set_decay_rate(const T &decay_rate_in) {
inline void set_decay_rate(const Value_Type &decay_rate_in) {
this->decay_rate = decay_rate_in;
}

inline void set_division_min(const T &division_min_in) {
inline void set_division_min(const Value_Type &division_min_in) {
this->division_min = division_min_in;
}

Expand Down Expand Up @@ -751,11 +751,11 @@ class LinalgLstsqSolver {
return Matrix<DefDense, T, N, K>(this->X_1);
}

inline void set_decay_rate(const T &decay_rate_in) {
inline void set_decay_rate(const Value_Type &decay_rate_in) {
this->decay_rate = decay_rate_in;
}

inline void set_division_min(const T &division_min_in) {
inline void set_division_min(const Value_Type &division_min_in) {
this->division_min = division_min_in;
}

Expand All @@ -771,9 +771,10 @@ class LinalgLstsqSolver {
/* Properties */
Base::Matrix::Matrix<T, N, K> X_1;

T decay_rate = static_cast<T>(0);
T division_min = static_cast<T>(DEFAULT_DIVISION_MIN_LINALG_SOLVER);
std::array<T, K> rho;
Value_Type decay_rate = static_cast<Value_Type>(0);
Value_Type division_min =
static_cast<Value_Type>(DEFAULT_DIVISION_MIN_LINALG_SOLVER);
std::array<Value_Type, K> rho;
std::array<std::size_t, K> rep_num;
};

Expand Down
11 changes: 11 additions & 0 deletions python_numpy/python_numpy_transpose_operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "python_numpy_templates.hpp"

#include <cstddef>
#include <utility>

namespace PythonNumpy {

Expand Down Expand Up @@ -103,6 +104,11 @@ A_mul_BTranspose(const Matrix<DefSparse, T, M, K, SparseAvailable_A> &A,
matrix_multiply_SparseA_mul_SparseBTranspose(A.matrix, B.matrix));
}

/* A_mul_BTranspose Type */
template <typename A_Type, typename B_Type>
using A_mul_BTranspose_Type =
decltype(A_mul_BTranspose(std::declval<A_Type>(), std::declval<B_Type>()));

/* (transpose matrix) * (matrix) */
template <typename T, std::size_t M, std::size_t K, std::size_t N>
inline auto ATranspose_mul_B(const Matrix<DefDense, T, N, M> &A,
Expand Down Expand Up @@ -199,6 +205,11 @@ ATranspose_mul_B(const Matrix<DefSparse, T, N, M, SparseAvailable_A> &A,
B.matrix));
}

/* ATranspose_mul_B Type */
template <typename A_Type, typename B_Type>
using ATranspose_mul_B_Type =
decltype(ATranspose_mul_B(std::declval<A_Type>(), std::declval<B_Type>()));

} // namespace PythonNumpy

#endif // __PYTHON_NUMPY_TRANSPOSE_OPERATION_HPP__
19 changes: 12 additions & 7 deletions test_vs/check_python_numpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ void CheckPythonNumpy<T>::check_python_numpy_base(void) {
tester.expect_near(Dense_mul_Dense.matrix.data, Dense_mul_Dense_answer.matrix.data, NEAR_LIMIT_STRICT,
"check DenseMatrix multiply DenseMatrix.");

auto Dense_mul_Diag = AA * B;
A_Multiply_B_Type<decltype(AA), decltype(B)>
Dense_mul_Diag = AA * B;

Matrix<DefDense, T, 4, 3> Dense_mul_Diag_answer({
{ 1, 6, 0 },
Expand Down Expand Up @@ -1846,7 +1847,7 @@ void CheckPythonNumpy<T>::check_python_numpy_transpose(void) {
CL({ 1, 3, 2, 8, 4, 1 });

/* 転置 */
auto AT = A.transpose();
Transpose_Type<decltype(A)> AT = A.transpose();

Matrix<DefDense, T, 3, 3> AT_answer({
{1, 5, 9},
Expand All @@ -1857,7 +1858,7 @@ void CheckPythonNumpy<T>::check_python_numpy_transpose(void) {
tester.expect_near(AT.matrix.data, AT_answer.matrix.data, NEAR_LIMIT_STRICT,
"check transpose Dense.");

auto CL_T = CL.transpose();
Transpose_Type<decltype(CL)> CL_T = CL.transpose();
auto CL_T_dense = CL_T.create_dense();

Matrix<DefDense, T, 3, 4> CL_T_answer({
Expand Down Expand Up @@ -2061,7 +2062,8 @@ void CheckPythonNumpy<T>::check_python_numpy_transpose_operation(void) {


/* 転置積 */
auto A_At = A_mul_BTranspose(A, A);
A_mul_BTranspose_Type<decltype(A), decltype(A)> A_At
= A_mul_BTranspose(A, A);

Matrix<DefDense, T, 3, 3> A_At_answer({
{14, 31, 46},
Expand Down Expand Up @@ -2152,7 +2154,8 @@ void CheckPythonNumpy<T>::check_python_numpy_transpose_operation(void) {
tester.expect_near(C_Bt_dense.matrix.data, C_Bt_answer.matrix.data, NEAR_LIMIT_STRICT,
"check A_mul_BTranspose Sparse and Diag.");

auto C_Ct = A_mul_BTranspose(C, C);
A_mul_BTranspose_Type<decltype(C), decltype(C)> C_Ct
= A_mul_BTranspose(C, C);
auto C_Ct_dense = C_Ct.create_dense();

Matrix<DefDense, T, 3, 3> C_Ct_answer({
Expand All @@ -2164,7 +2167,8 @@ void CheckPythonNumpy<T>::check_python_numpy_transpose_operation(void) {
tester.expect_near(C_Ct_dense.matrix.data, C_Ct_answer.matrix.data, NEAR_LIMIT_STRICT,
"check A_mul_BTranspose Sparse and Sparse.");

auto At_A = ATranspose_mul_B(A, A);
ATranspose_mul_B_Type<decltype(A), decltype(A)> At_A
= ATranspose_mul_B(A, A);

Matrix<DefDense, T, 3, 3> At_A_answer({
{107, 94, 96},
Expand Down Expand Up @@ -2255,7 +2259,8 @@ void CheckPythonNumpy<T>::check_python_numpy_transpose_operation(void) {
tester.expect_near(Ct_B_dense.matrix.data, Ct_B_answer.matrix.data, NEAR_LIMIT_STRICT,
"check ATranspose_mul_B Sparse and Diag.");

auto Ct_C = ATranspose_mul_B(C, C);
ATranspose_mul_B_Type<decltype(C), decltype(C)> Ct_C
= ATranspose_mul_B(C, C);
auto Ct_C_dense = Ct_C.create_dense();

Matrix<DefDense, T, 3, 3> Ct_C_answer({
Expand Down