Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun hi (a)
- (let
- ((frequenceX (make-list (array-dimension a 0)))
- (frequenceY (make-list (array-dimension a 1)))
- (sum 0))
- (dotimes (i (array-dimension a 0))
- (dotimes (j (array-dimension a 1))
- (progn (setf (elt frequenceX i) (+ (elt frequenceX i) (aref a i j)))
- (setf (elt frequenceY j) (+ (elt frequenceX j) (aref a j i))))))
- (dotimes (i (array-dimension a 0))
- (dotimes (j (array-dimension a 1))
- (incf sum (/ (* (aref a i j) (aref a i j)) (* (elt frequenceX i) (elt frequenceY j))))))
- sum))
- (hi (make-array '(10 10) :initial-contents
- '((0 0 0 1 1 2 1 1 0 1)
- (1 0 0 4 2 4 3 2 1 0)
- (0 3 3 8 11 7 4 2 1 0)
- (2 5 5 12 14 17 11 2 1 2)
- (4 3 6 21 21 13 10 8 3 1)
- (1 5 12 13 23 25 7 5 5 1)
- (3 7 5 16 8 13 12 2 1 0)
- (0 5 8 9 4 5 4 1 1 0)
- (0 0 2 2 3 4 0 1 0 0)
- (1 0 6 2 1 1 2 0 0 0))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement