tmatrix2.nim 443 B

1234567891011121314151617181920212223
  1. discard """
  2. output: "5.0"
  3. """
  4. type
  5. TMatrixNM*[M, N, T] = object
  6. aij*: T
  7. TVectorN*[N, T] = TMatrixNM[range[0..0], N, T]
  8. TVector3*[T] = TVectorN[range[0..2], T]
  9. proc coeffRef*[M, N, T] (matrix: var TMatrixNM[M, N, T], a: M, b: N): var T =
  10. return matrix.aij
  11. proc coeffRef*[N, T] (vector: var TVectorN[N, T], i: N): var T = vector.aij
  12. var
  13. testVar: TVector3[float]
  14. testVar.aij = 2.0
  15. testVar.coeffRef(1) = 5.0
  16. echo testVar.aij