Changeset 187 for trunk/blade/BladeDemo.d
- Timestamp:
- 04/30/08 16:05:32 (6 months ago)
- Files:
-
- trunk/blade/BladeDemo.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/blade/BladeDemo.d
r172 r187 1 1 // Written in the D programming language 1.0. 2 2 /** 3 * BLADE 0.3Alpha -- Basic Linear Algebra D Expressions3 * BLADE Alpha -- Basic Linear Algebra D Expressions 4 4 * 5 5 */ … … 9 9 import std.stdio; 10 10 11 // Local arrays in D aren't aligned to 128-bit boundaries.11 // Local arrays in D aren't currently aligned to 128-bit boundaries. 12 12 // In such cases, the library generates an 'SSE misalignment' assert error, 13 13 // to avoid segfaults. 14 14 // Use heap-allocated arrays, or static arrays (DMD 1.023 or later) 15 15 // cdouble[] always remains aligned, even when sliced. 16 16 17 17 void main() 18 { 18 { 19 19 static z = [3.4, 565, 31.3, 0]; 20 20 double [] a = new double[4]; … … 29 29 r[i]= q[i]*2213.3L; 30 30 } 31 double [4][] another = [[33.1, 4543, 43, 878.7], 31 double [4][] another = [[33.1, 4543, 43, 878.7], 32 32 [5.14, 455, 554, 2.43]]; 33 33 real k=3.4; 34 35 34 mixin(vectorize(` a += (d[2..$-1]*2.01*a[2]-another[][1])["abc".length-3..$]`)); 36 mixin(vectorize(" a-= 2.01*( 3.04+k)*r")); 37 35 mixin(vectorize(" a-= 2.01*( 3.04+k)*r")); 36 38 37 mixin(vectorize("q+= q*2.01")); 39 38 mixin(vectorize("another[0]+=r-=another[0]+another[0]")); 40 39 41 40 // All of the next four are equivalent 42 41 mixin(vectorize("a+=6*another[1,0..$]")); 43 42 mixin(vectorize("a+=6*(another[1,0..$]+another[1,0..$])")); 44 43 45 44 46 45 mixin(vectorize("a+=6*another[1][0..$]")); … … 49 48 // I don't think I'll support this syntax long-term. 50 49 mixin(vectorize("a+=6*another[1,[0,$]]")); 51 50 52 51 // Strided vector 53 52 mixin(vectorize("another[0..$,1]=6*a[0..2]")); … … 61 60 mixin(vectorize("a = -a")); 62 61 mixin(vectorize("u = sum(sqrt(abs(p))) + sum(sqrt(abs(q)))")); 62 mixin(vectorize("u = prod(q)")); 63 writefln("a=", a); 63 64 64 writefln("a=", a);65 65 }
