It can be done. How about something like below for a simple SPMV (vector matrix multiplication), with a sparse matrix presented in COO format (the simplest rare format):
class COO {
int x, y, value;
}
public static ArrayList<Integer> spmv(List<COO> values, ArrayList<Integer> v) {
final ArrayList<Integer> result = new ArrayList<>(Collections.nCopies(v.size(), 0));
values.stream().forEach(
coo -> result.set(coo.x, result.get(coo.x) + coo.value * v.get(coo.y))
);
return result;
}
- , 3 .
/, , ( ):
, . , :
, , - la4j .