Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions python/utils/gen_dense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import numpy as np
import sys

gen_dense_specs = {
"small": ((2, 8), (2, 8)),
"medium": ((20, 50), (20, 50)),
"large": ((100, 200), (100, 200)),
"skewed-row": ((500, 600), (1, 10)),
"skewed-col": ((1, 10), (500, 600))
}

def print_dense(fout, A):
fout.write(f"{A.shape[0]} {A.shape[1]}\n")
for i in range(A.shape[1]):
for j in range(A.shape[0]):
fout.write(f"{A[j, i]}\n")
fout.write("\n")

def gen_dense(nrows, ncols):
A = np.random.rand(nrows, ncols) * 100 - 50
return A

def gen_dense_spec(spec):
row_range, col_range = gen_dense_specs[spec]
return gen_dense(np.random.randint(row_range[0], row_range[1]), np.random.randint(col_range[0], col_range[1]))

if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python gen_dense.py <spec> <output file>")
print("Available specs:")
for n, _ in gen_dense_specs.items():
print(n)
elif sys.argv[1] == "resize":
A = gen_dense_spec("medium")
x, y = A.shape
B = np.zeros((x + np.random.randint(-20, 21), y + np.random.randint(-20, 21)))
B[:min(x, B.shape[0]), :min(y, B.shape[1])] = A[:min(x, B.shape[0]), :min(y, B.shape[1])]
with open(sys.argv[2], "w") as fout:
print_dense(fout, A)
print_dense(fout, B)
elif sys.argv[1] == "appendv":
A = gen_dense_spec("medium")
x, y = A.shape
B = gen_dense(np.random.randint(20, 50), y)
C = np.vstack([A, B])
with open(sys.argv[2], "w") as fout:
print_dense(fout, A)
print_dense(fout, B)
print_dense(fout, C)
else:
A = gen_dense_spec(sys.argv[1])
with open(sys.argv[2], "w") as fout:
print_dense(fout, A)
2 changes: 1 addition & 1 deletion src/igo.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ int igo_resize_dense (
igo_common* igo_cm
) ;

/* Perform [igo_B->B; Bhat] = [igo_B->B; Bhat].
/* Perform igo_B->B = [igo_B->B; Bhat].
* This is needed because cholmod_horzcat makes copies of the inputs */
int igo_vertappend_dense (
/* --- input --- */
Expand Down
8 changes: 4 additions & 4 deletions src/igo_sparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ int igo_horzappend_sparse (
}

int copy_size = newnzmax - oldnzmax;
memcpy(A->i + old_maxAp * sizeof(int), B->i, copy_size * sizeof(int));
memcpy(A->x + old_maxAp * sizeof(double), B->x, copy_size * sizeof(double));
memcpy((char*)A->i + old_maxAp * sizeof(int), B->i, copy_size * sizeof(int));
memcpy((char*)A->x + old_maxAp * sizeof(double), B->x, copy_size * sizeof(double));

return 1;
}
Expand Down Expand Up @@ -429,8 +429,8 @@ int igo_horzappend_sparse_pattern (
}

int copy_size = newnzmax - oldnzmax;
memcpy(A->i + old_maxAp * sizeof(int), B->i, copy_size * sizeof(int));
memset(A->x + old_maxAp * sizeof(double), 0, copy_size * sizeof(double));
memcpy((char*)A->i + old_maxAp * sizeof(int), B->i, copy_size * sizeof(int));
memset((char*)A->x + old_maxAp * sizeof(double), 0, copy_size * sizeof(double));

return 1;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/pregen_inputs/test_allocate_sparse2_4_4.tri
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
4 4 7 0
0 0 1
0 1 1
1 1 1
1 2 1
2 2 1
2 3 1
3 3 1
200 changes: 200 additions & 0 deletions tests/pregen_inputs/test_cholmod_updown2_20_50.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
%%MatrixMarket matrix coordinate real general
20 50 95
0 0 0
0 0 0.01
1 1 0.01
2 2 0.01
3 3 0.01
4 4 0.01
5 5 0.01
6 6 0.01
7 7 0.01
8 8 0.01
9 9 0.01
10 10 0.01
11 11 0.01
12 12 0.01
13 13 0.01
14 14 0.01
15 15 0.01
16 16 0.01
17 17 0.01
18 18 0.01
19 19 0.01
7 20 4.778372796694137
13 20 3.713039078862905
15 20 0.9733704154308748
4 21 0.5065973858921546
10 21 1.3403161901270588
5 22 3.735806641649211
7 22 0.9036154307967598
18 22 3.456534078854674
1 23 2.327725838430914
7 23 2.0841575859054555
19 23 0.8773603749616049
0 24 2.3565347211790915
5 24 2.052501811951238
6 24 1.8558902977475427
5 25 3.9097026636446177
12 25 4.529024008193556
19 25 2.9254611831642774
1 26 2.2107305982147003
6 26 0.0022135556550212376
12 26 1.3234876418430424
8 27 4.049968544430118
19 27 1.2098228506611142
11 28 3.9831154743713997
14 28 1.6267143121646326
6 29 4.51929589377548
9 29 2.59692161175753
13 29 4.95737101596888
4 30 3.153815751593141
14 30 0.27552315974958774
15 30 1.8423822958510794
7 31 0.04796588952193648
13 31 2.521240976446044
0 32 4.511991837816237
6 32 0.8109443420735324
17 32 0.6803360969914474
0 33 3.6128931383713043
1 33 2.975789316891697
6 33 2.946026269676587
0 34 1.9780924703800267
4 34 4.1332164373688105
11 34 2.5549401139409906
8 35 4.406664738102367
11 35 2.266448389594253
3 36 3.862668917658346
5 36 4.958470130917943
15 36 1.5004090624147681
8 37 3.702127672502577
10 37 2.22246096843365
17 37 0.7994122445232793
5 38 2.4259758205542656
7 38 1.7790392409340843
15 39 0.9689323131576949
17 39 3.087995080187223
1 40 2.3781739230507033
17 40 1.1387798955849342
1 41 0.3558250350671688
2 41 0.8619005886925507
9 41 2.2979587669419796
5 42 1.2329129403299277
12 42 1.3235120576790094
3 43 1.8388173250045603
8 43 1.207903614201491
1 44 3.516886759434905
15 44 4.573577267199483
12 45 0.5165680410846285
17 45 2.0611892594466785
11 46 2.2404373978329133
15 46 2.282899781586854
1 47 1.0941448618593679
15 47 3.174953125823195
0 48 2.0529075944827513
9 48 1.6530324164014343
8 49 3.4048638619912457
17 49 4.208361376009401

%%MatrixMarket matrix coordinate real general
20 50 26
0 0 0
0 24 0.16555099316369115
5 24 2.318661841505538
6 24 3.2816366861025066
1 26 3.6201528063423116
6 26 4.8896143359656765
12 26 4.112544785245522
11 28 3.6021601125194573
14 28 1.0464039351909578
6 29 4.374784759228271
9 29 3.1658865664288345
13 29 3.8036693449828007
4 30 4.564478169081645
14 30 4.596164395797787
15 30 2.2939534155136805
7 31 2.1524672368594917
13 31 0.2917640049616671
8 35 1.830212055473563
11 35 0.024767871768291427
8 37 1.2710090513462002
10 37 0.6295639774700967
17 37 0.5323930558352374
5 42 2.05323106270114
12 42 1.0854689105386357
1 44 1.1623913127165757
15 44 3.4497219822989598

%%MatrixMarket matrix coordinate real general
20 50 26
0 0 0
0 24 2.3565347211790915
5 24 2.052501811951238
6 24 1.8558902977475427
1 26 2.2107305982147003
6 26 0.0022135556550212376
12 26 1.3234876418430424
11 28 3.9831154743713997
14 28 1.6267143121646326
6 29 4.51929589377548
9 29 2.59692161175753
13 29 4.95737101596888
4 30 3.153815751593141
14 30 0.27552315974958774
15 30 1.8423822958510794
7 31 0.04796588952193648
13 31 2.521240976446044
8 35 4.406664738102367
11 35 2.266448389594253
8 37 3.702127672502577
10 37 2.22246096843365
17 37 0.7994122445232793
5 42 1.2329129403299277
12 42 1.3235120576790094
1 44 3.516886759434905
15 44 4.573577267199483

20 1
4.422882785916739
1.5429458060225865
3.7068387446717272
2.5212793973937693
0.2686695848839149
0.9385502123496081
3.7408959158483457
3.610277194810043
3.1140526295629556
0.5036880360104656
2.4637763360953753
2.3696541961412794
3.0484868550973006
3.439037514379626
3.2625633502482785
0.3920782698786818
2.9880642434171856
3.2352018376231984
2.5701092660157094
0.3466525286615679

20 1
4.469774552370194
4.117646891957635
0.0
0.0
4.490287882723264
4.5049823773236
1.2131439933963333
2.3471511749278773
4.53363743819171
0.7469439730173866
0.8834415285309916
1.3258282788720221
4.216103844688448
4.569115256613166
1.7577332111369948
3.5161912813407756
0.0
4.492688760941411
0.0
0.0

Loading