/lib/packages/docutils/

s'> This repository contains the Nim compiler, Nim's stdlib, tools, and documentation. (mirror)ahoang <ahoang@tilde.institute>
summary refs log blame commit diff stats
path: root/tests/concepts/matrixalgo.nim
blob: 98e5b8b4f147ef6dc21c7b8743faee214ca07a5b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                
                                                        





                                                          

                       







                                                   
import typetraits

type
  AnyMatrix*[R, C: static[int]; T] = concept m, var mvar, type M
    M.ValueType is T
    M.Rows == R
    M.Cols == C

    m[int, int] is T
    mvar[int, int] = T

    type TransposedType = stripGenericParams(M)[C, R, T]

  AnySquareMatrix*[N: static[int], T] = AnyMatrix[N, N, T]

  AnyTransform3D* = AnyMatrix[4, 4, float]

proc transposed*(m: AnyMatrix): m.TransposedType =
  for r in 0 ..< m.R:
    for c in 0 ..< m.C:
      result[r, c] = m[c, r]

proc determinant*(m: AnySquareMatrix): int =
  return 0

proc setPerspectiveProjection*(m: AnyTransform3D) =
  discard