Commit df171bd25d6b1c43f1d94bb0ffd3a0dc8a1567af

Authored by David Mayerich
2 parents eaaf04c2 42bb075c

Merge branch 'JACK' into 'master'

last changes for tensor-code project. add operator for struct matrix.

See merge request !17
Showing 2 changed files with 13 additions and 3 deletions   Show diff stats
stim/math/matrix.h
... ... @@ -64,6 +64,16 @@ struct matrix
64 64  
65 65 return *this;
66 66 }
  67 +
  68 + // M - rhs*I
  69 + CUDA_CALLABLE matrix<T, N> operator-(T rhs)
  70 + {
  71 + for(int i=0; i<N; i++)
  72 + for(int j=0 ; j<N; j++)
  73 + if(i == j)
  74 + M[i*N+j] -= rhs;
  75 + return *this;
  76 + }
67 77  
68 78 template<typename Y>
69 79 vec<Y> operator*(vec<Y> rhs){
... ...
stim/math/tensor3.h
... ... @@ -80,11 +80,11 @@ namespace stim {
80 80 stim::matrix<T, 3> M2 = matrix_sym<T, 3>::mat();
81 81 stim::matrix<T, 3> M3 = matrix_sym<T, 3>::mat(); // fill a tensor with symmetric values
82 82  
83   - M1.operator_minus(M1, lambda[0]); // M1 = A - lambda[0] * I
  83 + M1 = M1 - lambda[0]; // M1 = A - lambda[0] * I
84 84  
85   - M2.operator_minus(M2, lambda[1]); // M2 = A - lambda[1] * I
  85 + M2 = M2 - lambda[1]; // M2 = A - lambda[1] * I
86 86  
87   - M3.operator_minus(M3, lambda[2]); // M3 = A - lambda[2] * I
  87 + M3 = M3 - lambda[2]; // M3 = A - lambda[2] * I
88 88  
89 89 T Mod = 0; // module of one column
90 90  
... ...