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.

43 lines
742 B

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