mirror of
https://github.com/socathie/circomlib-ml.git
synced 2026-01-09 14:08:04 -05:00
22 lines
423 B
Plaintext
22 lines
423 B
Plaintext
pragma circom 2.0.0;
|
|
|
|
// sum of all elements in a matrix
|
|
template matElemSum (m,n) {
|
|
signal input a[m][n];
|
|
signal output out;
|
|
|
|
signal sum[m*n];
|
|
sum[0] <== a[0][0];
|
|
var idx = 0;
|
|
|
|
for (var i=0; i < m; i++) {
|
|
for (var j=0; j < n; j++) {
|
|
if (idx > 0) {
|
|
sum[idx] <== sum[idx-1] + a[i][j];
|
|
}
|
|
idx++;
|
|
}
|
|
}
|
|
|
|
out <== sum[m*n-1];
|
|
} |