@@ -13,7 +13,7 @@ fn printArray(comptime T: type, arr: num.NDArray(T)) !void {
1313 for (0.. arr .shape [0 ]) | i | {
1414 std .debug .print (" [ " , .{});
1515 for (0.. arr .shape [1 ]) | j | {
16- std .debug .print ("{d:.2} " , .{try arr .get (&.{i , j })});
16+ std .debug .print ("{d:.2} " , .{try arr .get (&.{ i , j })});
1717 }
1818 std .debug .print ("]\n " , .{});
1919 }
@@ -32,9 +32,9 @@ pub fn main() !void {
3232
3333 // --- Test CSV I/O ---
3434 std .debug .print ("\n --- CSV I/O ---\n " , .{});
35-
35+
3636 // Create a dummy CSV file
37- const csv_content =
37+ const csv_content =
3838 \\1.0,2.0,3.0
3939 \\4.0,5.0,6.0
4040 \\7.0,8.0,9.0
@@ -46,7 +46,7 @@ pub fn main() !void {
4646 // Read CSV
4747 var csv_arr = try num .io .readCSV (allocator , f64 , "test.csv" );
4848 defer csv_arr .deinit ();
49-
49+
5050 std .debug .print ("Read CSV:\n " , .{});
5151 try printArray (f64 , csv_arr );
5252
@@ -57,18 +57,24 @@ pub fn main() !void {
5757
5858 // --- Test LU Decomposition ---
5959 std .debug .print ("\n --- LU Decomposition ---\n " , .{});
60-
61- var mat = try num .NDArray (f64 ).init (allocator , &.{3 , 3 });
60+
61+ var mat = try num .NDArray (f64 ).init (allocator , &.{ 3 , 3 });
6262 defer mat .deinit ();
63-
63+
6464 // A = [[4, 3], [6, 3]] -> L=[[1,0],[1.5,1]], U=[[4,3],[0,-1.5]]
6565 // Let use a 3x3 example:
6666 // 1 2 3
6767 // 4 5 6
6868 // 7 8 10 (changed 9 to 10 to be non-singular)
69- mat .data [0 ] = 1 ; mat .data [1 ] = 2 ; mat .data [2 ] = 3 ;
70- mat .data [3 ] = 4 ; mat .data [4 ] = 5 ; mat .data [5 ] = 6 ;
71- mat .data [6 ] = 7 ; mat .data [7 ] = 8 ; mat .data [8 ] = 10 ;
69+ mat .data [0 ] = 1 ;
70+ mat .data [1 ] = 2 ;
71+ mat .data [2 ] = 3 ;
72+ mat .data [3 ] = 4 ;
73+ mat .data [4 ] = 5 ;
74+ mat .data [5 ] = 6 ;
75+ mat .data [6 ] = 7 ;
76+ mat .data [7 ] = 8 ;
77+ mat .data [8 ] = 10 ;
7278
7379 std .debug .print ("Matrix A:\n " , .{});
7480 try printArray (f64 , mat );
@@ -88,12 +94,20 @@ pub fn main() !void {
8894 std .debug .print ("\n --- Boolean Masking ---\n " , .{});
8995 var data = try num .NDArray (f64 ).init (allocator , &.{5 });
9096 defer data .deinit ();
91- data .data [0 ] = 10 ; data .data [1 ] = 20 ; data .data [2 ] = 30 ; data .data [3 ] = 40 ; data .data [4 ] = 50 ;
97+ data .data [0 ] = 10 ;
98+ data .data [1 ] = 20 ;
99+ data .data [2 ] = 30 ;
100+ data .data [3 ] = 40 ;
101+ data .data [4 ] = 50 ;
92102
93103 var mask = try num .NDArray (bool ).init (allocator , &.{5 });
94104 defer mask .deinit ();
95105 // Mask: [true, false, true, false, true]
96- mask .data [0 ] = true ; mask .data [1 ] = false ; mask .data [2 ] = true ; mask .data [3 ] = false ; mask .data [4 ] = true ;
106+ mask .data [0 ] = true ;
107+ mask .data [1 ] = false ;
108+ mask .data [2 ] = true ;
109+ mask .data [3 ] = false ;
110+ mask .data [4 ] = true ;
97111
98112 var masked = try num .indexing .booleanMask (allocator , f64 , data , mask );
99113 defer masked .deinit ();
@@ -104,8 +118,7 @@ pub fn main() !void {
104118 // printArray(bool, mask) won't work because printArray expects {d:.2} format which is for numbers.
105119 // I'll skip printing mask or implement printArrayBool
106120 std .debug .print ("Mask: [true, false, true, false, true]\n " , .{});
107-
121+
108122 std .debug .print ("Masked Result (should be 10, 30, 50):\n " , .{});
109123 try printArray (f64 , masked );
110-
111124}
0 commit comments