-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathinit_rcarray.d
More file actions
39 lines (33 loc) · 812 Bytes
/
init_rcarray.d
File metadata and controls
39 lines (33 loc) · 812 Bytes
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
module init_rcarray;
import mir.ndslice;
import mir.rc.array;
import mir.rc.ptr;
// force template instatiations
alias RCArrayDouble = RCArray!double;
alias RCArrayInt = RCArray!int;
extern(C++)
struct S { double d = 0; this(double e) { d = e;} }
extern(C++)
struct C { double k = 0; S s; }
alias SPtr = RCPtr!S;
alias CPtr = RCPtr!C;
extern(C++, Space)
{
void initWithIota(ref RCArray!double a)
{
foreach(i, ref e; a)
e = i;
}
void reverseRcSlice(ref Slice!(RCI!double) a)
{
import mir.utility: swap;
foreach(i; 0 .. a.length / 2)
swap(a[i], a[$ - 1 - i]);
}
void reverseRcSlice(ref Slice!(RCI!int) a)
{
import mir.utility: swap;
foreach(i; 0 .. a.length / 2)
swap(a[i], a[$ - 1 - i]);
}
}