1 ;;; -*- mode: lisp; coding: utf-8 -*-
3 (in-package :cl-jama-test)
7 (n (length (first x))))
8 (make-array (list m n) :initial-contents x)))
10 (defun make-vector (x)
11 (make-array (list (length x)) :initial-contents x))
13 (defun dump-matrix (x &optional (s *standard-output*) (w 11) (d 4))
14 (loop :for i :from 0 :below (array-dimension x 0)
15 :do (loop :for j :from 0 :below (array-dimension x 1)
16 :do (format s "~V,VF" w d (aref x i j)))
20 (defun dump-vector (x &optional (s *standard-output*))
21 (loop :for i :from 0 :below (array-dimension x 0)
22 :do (format s "~11,4F" (aref x i)))
28 (deftest make-matrix.1
29 (make-matrix '((1.23 -2.34 3.45) (-4.56 5.67 -6.78)))
30 #2A((1.23 -2.34 3.45) (-4.56 5.67 -6.78)))
32 (deftest make-vector.1
33 (make-vector '(9.87 -8.76 7.65))
36 (deftest dump-matrix.1
37 (with-output-to-string (os) (dump-matrix #2A((1.23 -2.34 3.45) (-4.56 5.67 -6.78)) os))
38 " 1.2300 -2.3400 3.4500
39 -4.5600 5.6700 -6.7800
42 (deftest dump-vector.1
43 (with-output-to-string (os) (dump-vector #(9.87 -8.76 7.65) os))
44 " 9.8700 -8.7600 7.6500
48 (copy-array #(1.23 -2.34 3.45))
52 (copy-array #2A((-4.56 5.67 -6.78) (7.89 -8.90 9.01)))
53 #2A((-4.56 5.67 -6.78) (7.89 -8.90 9.01)))
56 (transpose #2A((-4.56 5.67 -6.78) (7.89 -8.90 9.01)))
57 #2A((-4.56 7.89) (5.67 -8.90) (-6.78 9.01)))
60 (multiply #2A((1 1 1) (2 2 2) (3 3 3)) #2A((1 2 3) (1 2 3) (1 2 3)))
61 #2A((3 6 9) (6 12 18) (9 18 27)))