Working test cases for the sophisticated matrix library example from the manual
Fixed the dot operator when used within return types (see tgenericdotrettype) Fixed the matching of generic concepts aliases used with the implicit generics style
This commit is contained in:
parent
52b241fd57
commit
cbf66e99a8
12 changed files with 211 additions and 53 deletions
28
tests/concepts/matrixalgo.nim
Normal file
28
tests/concepts/matrixalgo.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue