matrix.alc 429 B

123456789101112131415161718192021222324
  1. include "primitives.alh"
  2. include "random.alh"
  3. Element function create_random_matrix(n : Integer):
  4. Element m
  5. Integer i
  6. Integer j
  7. Element t
  8. // Construct the matrix first, with as many rows as there are variables
  9. // Number of columns is 1 higher
  10. i = 0
  11. m = create_node()
  12. while (i < n):
  13. j = 0
  14. t = create_node()
  15. while (j < (n + 1)):
  16. list_append(t, random())
  17. j = j + 1
  18. list_append(m, t)
  19. i = i + 1
  20. return m!