-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp.t
72 lines (53 loc) · 1.82 KB
/
temp.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--[[
local DynamicVector = function(T)
--generate the raw type
local DVector = DArrayRawType(T, 1)
function DVector.metamethods.__typename(self)
return ("DynamicVector(%s)"):format(tostring(T))
end
--add base functionality
base.AbstractBase(DVector)
--implement interfaces
DArrayStackBase(DVector)
DArrayVectorBase(DVector)
DArrayIteratorBase(DVector)
veccont.VectorContiguous:addimplementations{DVector}
if concepts.BLASNumber(T) then
terra DVector:getblasinfo()
return self:length(), self:getdataptr(), 1
end
end
assert(vecbase.Vector(DVector))
return DVector
end
local DynamicMatrix = function(T, options)
local DMatrix = DArrayRawType(T, 2, options)
--check that a matrix-type was generated
assert(DMatrix.ndims == 2, "ArgumentError: expected an array of dimension 2.")
function DMatrix.metamethods.__typename(self)
local perm = "{"
for i = 1, Array.ndims-1 do
perm = perm .. tostring(Array.perm[i]) .. ","
end
perm = perm .. tostring(Array.perm[Array.ndims]) .. "}"
return "DynamicMatrix(" .. tostring(T) ..", " .. tostring(Array.ndims) .. ", perm = " .. perm .. ")"
end
--add base functionality
base.AbstractBase(DMatrix)
--implement interfaces
DArrayStackBase(DMatrix)
DArrayVectorBase(DMatrix)
DArrayIteratorBase(DMatrix)
--add linear operator functionality
matbase.MatrixBase(DMatrix)
if concepts.BLASNumber(T) then
terra DMatrix:getblasdenseinfo()
return self:size(0), self:size(1), self:getdataptr(), self:size(1)
end
local matblas = require("matrix_blas_dense")
matblas.BLASDenseMatrixBase(DMatrix)
end
assert(matbase.Matrix(DMatrix))
return DMatrix
end
--]]