Skip to content

Commit b45205a

Browse files
Add files via upload
1 parent fa80dd5 commit b45205a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Mathematica/dyadicmemoryC.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ and associated documentation files (the “Software”), to deal in the Software
5353
f[x_SparseArray] := Module[ {a},
5454
WriteLine[ process, tostr[x] ];
5555
a = ToExpression /@ StringSplit[ReadLine[process]]; SparseArray[ a -> Table[1, Length[a]], {n}]];
56+
57+
f["Quit"] := KillProcess[process]
5658

5759
];
5860

@@ -82,7 +84,9 @@ and associated documentation files (the “Software”), to deal in the Software
8284
f[x_SparseArray] := Module[ {a},
8385
WriteLine[ process, tostr[x] ];
8486
a = ToExpression /@ StringSplit[ReadLine[process]]; SparseArray[ a -> Table[1, Length[a]], {n2}]];
85-
87+
88+
89+
f["Quit"] := KillProcess[process]
8690
];
8791

8892

Mathematica/triadicmemoryC.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ and associated documentation files (the “Software”), to deal in the Software
4444
tostr[_] = "_";
4545

4646
(* zero vector *)
47-
f[0] = SparseArray[_ -> 0, {n}];
47+
f[0] = SparseArray[{0}, {n}];
48+
49+
(* binarize x *)
50+
f[x_] := Module[ {t = Max[1, RankedMax[x, p]]}, SparseArray[Boole[# >= t] & /@ x]];
51+
4852

4953
(* store {x,y,z} *)
5054
f[x_SparseArray, y_SparseArray, z_SparseArray] :=
@@ -54,6 +58,8 @@ and associated documentation files (the “Software”), to deal in the Software
5458
f[x_, y_, z_] := Module[ {a},
5559
WriteLine[ process, "{" <> tostr[x] <> "," <> tostr[y] <> "," <> tostr[z] <> "}" ];
5660
a = ToExpression /@ StringSplit[ReadLine[process]]; SparseArray[ a -> Table[1, Length[a]], {n}]];
61+
62+
f["Quit"] := KillProcess[process]
5763

5864
];
5965

0 commit comments

Comments
 (0)