You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
737 B

5 years ago
5 years ago
5 years ago
5 years ago
  1. // arr1
  2. function Add3(arr1, arr2, arr3) {
  3. var res[3];
  4. res[0] = arr1;
  5. res[1] = 0;
  6. for (var i=0; i<2; i += 1) {
  7. res[1] = res[1] + arr2[i];
  8. }
  9. res[2] = 0;
  10. for (var i=0; i<2; i++) {
  11. for (var j=0; j<3; j += 1) {
  12. res[2] = res[2] + arr3[i][j];
  13. }
  14. }
  15. return res;
  16. }
  17. template Main() {
  18. signal input in;
  19. signal output out[3];
  20. var c[3] = Add3(1, [2,3], [[4,5,6], [7,8,9]]); // [1, 5, 39];
  21. var d[3] = Add3(in, [in+1, in+2], [[in+1, in+2, in+3], [in+1, in+2, in+3]]);
  22. out[0] <-- d[0] + c[0];
  23. out[0] === in+c[0];
  24. out[1] <-- d[1]+c[1];
  25. out[1] === 2*in+3+c[1];
  26. out[2] <-- d[2]+c[2];
  27. out[2] === 6*in+12+c[2];
  28. }
  29. component main = Main();