57 #ifdef MODULAR_FIXED_SIZE 58 # define N MODULAR_FIXED_SIZE 59 # define MATRIX_ELEM(mat, i, j) (mat[i][j]) 61 # define MATRIX_ELEM(mat, i, j) (mat[i * N + j]) 62 #endif // MODULAR_FIXED_SIZE 67 #ifdef MODULAR_FIXED_SIZE 68 static void modMatMat (MODULAR_NUMBER_TYPE A[N][N], MODULAR_NUMBER_TYPE B[N][N], MODULAR_NUMBER_TYPE C[N][N], MODULAR_NUMBER_TYPE
m)
70 void modMatMat (
size_t N, MODULAR_NUMBER_TYPE* A, MODULAR_NUMBER_TYPE* B, MODULAR_NUMBER_TYPE* C, MODULAR_NUMBER_TYPE m)
73 MODULAR_NUMBER_TYPE V[N];
74 MODULAR_NUMBER_TYPE W[N][N];
75 for (
size_t i = 0; i < N; ++i) {
76 for (
size_t j = 0; j < N; ++j)
78 #ifdef MODULAR_FIXED_SIZE 83 for (
size_t j = 0; j < N; ++j)
86 for (
size_t i = 0; i < N; ++i) {
87 for (
size_t j = 0; j < N; ++j)
95 #ifdef MODULAR_FIXED_SIZE 96 static void modMatPowLog2 (MODULAR_NUMBER_TYPE A[N][N], MODULAR_NUMBER_TYPE B[N][N], MODULAR_NUMBER_TYPE m, cl_uint e)
98 void modMatPowLog2 (
size_t N, MODULAR_NUMBER_TYPE* A, MODULAR_NUMBER_TYPE* B, MODULAR_NUMBER_TYPE m, cl_uint e)
103 for (
size_t i = 0; i < N; i++) {
104 for (
size_t j = 0; j < N; ++j)
109 for (cl_uint i = 0; i < e; i++)
110 #ifdef MODULAR_FIXED_SIZE
120 #ifdef MODULAR_FIXED_SIZE 121 static void modMatPow (MODULAR_NUMBER_TYPE A[N][N], MODULAR_NUMBER_TYPE B[N][N], MODULAR_NUMBER_TYPE m, cl_uint n)
123 void modMatPow (
size_t N, MODULAR_NUMBER_TYPE* A, MODULAR_NUMBER_TYPE* B, MODULAR_NUMBER_TYPE m, cl_uint n)
126 MODULAR_NUMBER_TYPE W[N][N];
129 for (
size_t i = 0; i < N; i++) {
130 for (
size_t j = 0; j < N; ++j) {
136 for (
size_t j = 0; j < N; ++j)
142 #ifdef MODULAR_FIXED_SIZE 147 modMatMat (N, &W[0][0], &W[0][0], &W[0][0], m);
void modMatPowLog2(size_t N, MODULAR_NUMBER_TYPE *A, MODULAR_NUMBER_TYPE *B, MODULAR_NUMBER_TYPE m, cl_uint e)
Compute matrix B = (A^(2^e) % m)
Definition: modularHost.c.h:98
void modMatVec(size_t N, MODULAR_NUMBER_TYPE *A, MODULAR_NUMBER_TYPE *s, MODULAR_NUMBER_TYPE *v, MODULAR_NUMBER_TYPE m)
Matrix-vector modular multiplication.
Definition: device/modular.c.h:81
void modMatPow(size_t N, MODULAR_NUMBER_TYPE *A, MODULAR_NUMBER_TYPE *B, MODULAR_NUMBER_TYPE m, cl_uint n)
Compute matrix B = A^n % m.
Definition: modularHost.c.h:123
#define MATRIX_ELEM(mat, i, j)
Definition: modularHost.c.h:61
void modMatMat(size_t N, MODULAR_NUMBER_TYPE *A, MODULAR_NUMBER_TYPE *B, MODULAR_NUMBER_TYPE *C, MODULAR_NUMBER_TYPE m)
Compute A*B % m.
Definition: modularHost.c.h:70
m
Definition: genn_model.py:117