-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray-test.ssc
More file actions
115 lines (93 loc) · 2.87 KB
/
Copy patharray-test.ssc
File metadata and controls
115 lines (93 loc) · 2.87 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Test file for Simple Simple C array declarations
// Single-dimensional array declarations
double arr1[5];
double arr2[10];
// Two-dimensional array declarations
double matrix1[3][3];
double matrix2[2][4];
// Three-dimensional array declarations
double cube[2][2][2];
double bigCube[4][4][4];
// Four-dimensional array declaration
double tesseract[2][2][2][2];
// Mixed dimensions
double mixed1[1][2][3][4][5];
double mixed2[10][1];
// Large array
double largeArray[100][100];
// Prime number dimensions
double primes[2][3][5][7][11];
// Test default initialization
double arr3[5][5][5] = default(4.0);
double arr4[2][3] = { {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0} };
// Test for default initialization
double arr5[5] = default(1.5);
double matrix[2][3] = default(3.14);
// Test for resizing
resize(arr3, [4, 6, 2]);
// Test for range initialization
//double arr6[5] = range(1.0, 5.0);
// Test for copying array
double arr7[3] = {1.0, 2.0, 3.0};
//double new_arr = copy(arr7); // new_arr will contain {1.0, 2.0, 3.0}
// Test for cloning the structure
double arr8[3][2] = {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}};
//double cloned_arr = clone_structure(arr8); // cloned_arr will be a 3x2 array filled with zeros
//cloned_arr[2][1] = 3.14;
// Test for length
double arr9[3][4][2];
int first_dim = length(arr9, 1);
int second_dim = length(arr9, 2);
int third_dim = length(arr9, 3);
// Test for array operations
double total = sum(arr7); // Returns 6.0
double highest = max(arr7); // Returns 3.0
double lowest = min(arr7); // Returns 1.0
double avg = average(arr7); // Returns 2.0
// Test for broadcasting
double arr1D[2] = {10.0, 20.0};
double arr2D[2][3] = {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}};
double result2[2][3];
result2 = arr1D + arr2D;
// Test for flattening arrays
double arrF[2][3] = {{1, 2, 3}, {4, 5, 6}};
double flat_arr = flatten(arrF);
// Test for reshape arrays
double arr10[6] = {1, 2, 3, 4, 5, 6};
double reshaped_arr[2][3] = reshape(arr10, 2, 3);
// Test for map and reduce
double arr11[5] = {1, 2, 3, 4, 5};
double squared = map(arr11, square);
double sumOfArray = reduce(arr11, add);
// Test for serialization
double arr12[5] = {1, 2, 3, 4, 5};
string serialized = serialize(arr12);
double new_arr2 = deserialize(serialized);
// Test for slices
//double arr13[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
//double row_slice = arr13[1:3][2:4];
printd(0);
printd(arr3[3][5][1]);
//printd(arr6[3]);
//printd(new_arr[1]);
//printd(cloned_arr[2][1]);
printi(first_dim);
printi(second_dim);
printi(third_dim);
printd(total);
printd(highest);
printd(lowest);
printd(avg);
printd(flat_arr[3]);
printd(result2[0][0]);
printd(result2[0][1]);
printd(result2[0][2]);
printd(result2[1][0]);
printd(result2[1][1]);
printd(result2[1][2]);
printd(reshaped_arr[0][2]);
printd(sumOfArray);
printd(squared[4]);
printd(new_arr2[4]);
prints(serialized);
prints("Array declarations test complete");