Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -23,7 +23,7 @@ Given the three vectors: <code>a = (3, 4, 5); b = (4, 3, 5); c = (-5, -12, -13
|
|||
|
||||
;References:
|
||||
* [[Dot product]] here on RC.
|
||||
* [http://mathworld.wolfram.com/VectorMultiplication.html A starting page] to the Wolfram Mathworld information on vector multiplication.
|
||||
* A starting page on Wolfram Mathworld is {{Wolfram|Vector|Mulitplication}}.
|
||||
* Wikipedias [[wp:Dot product|dot product]], [[wp:Cross product|cross product]] and [[wp:Triple product|triple product]] entries.
|
||||
|
||||
;C.f.
|
||||
|
|
|
|||
30
Task/Vector-products/Racket/vector-products.rkt
Normal file
30
Task/Vector-products/Racket/vector-products.rkt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#lang racket
|
||||
|
||||
(define (dot-product X Y)
|
||||
(for/sum ([x (in-vector X)] [y (in-vector Y)]) (* x y)))
|
||||
|
||||
(define (cross-product X Y)
|
||||
(define len (vector-length X))
|
||||
(for/vector ([n len])
|
||||
(define (ref V i) (vector-ref V (modulo (+ n i) len)))
|
||||
(- (* (ref X 1) (ref Y 2)) (* (ref X 2) (ref Y 1)))))
|
||||
|
||||
(define (scalar-triple-product X Y Z)
|
||||
(dot-product X (cross-product Y Z)))
|
||||
|
||||
(define (vector-triple-product X Y Z)
|
||||
(cross-product X (cross-product Y Z)))
|
||||
|
||||
(define A '#(3 4 5))
|
||||
(define B '#(4 3 5))
|
||||
(define C '#(-5 -12 -13))
|
||||
|
||||
(printf "A = ~s\n" A)
|
||||
(printf "B = ~s\n" B)
|
||||
(printf "C = ~s\n" C)
|
||||
(newline)
|
||||
|
||||
(printf "A . B = ~s\n" (dot-product A B))
|
||||
(printf "A x B = ~s\n" (cross-product A B))
|
||||
(printf "A . B x C = ~s\n" (scalar-triple-product A B C))
|
||||
(printf "A x B x C = ~s\n" (vector-triple-product A B C))
|
||||
Loading…
Add table
Add a link
Reference in a new issue