Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
23
Task/Vector-products/Phix/vector-products.phix
Normal file
23
Task/Vector-products/Phix/vector-products.phix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
function dot_product(sequence a, b)
|
||||
return sum(sq_mul(a,b))
|
||||
end function
|
||||
|
||||
function cross_product(sequence a, b)
|
||||
integer {a1,a2,a3} = a, {b1,b2,b3} = b
|
||||
return {a2*b3-a3*b2, a3*b1-a1*b3, a1*b2-a2*b1}
|
||||
end function
|
||||
|
||||
function scalar_triple_product(sequence a, b, c)
|
||||
return dot_product(a,cross_product(b,c))
|
||||
end function
|
||||
|
||||
function vector_triple_product(sequence a, b, c)
|
||||
return cross_product(a,cross_product(b,c))
|
||||
end function
|
||||
|
||||
constant a = {3, 4, 5}, b = {4, 3, 5}, c = {-5, -12, -13}
|
||||
|
||||
puts(1," a . b = ") ?dot_product(a,b)
|
||||
puts(1," a x b = ") ?cross_product(a,b)
|
||||
puts(1,"a . (b x c) = ") ?scalar_triple_product(a,b,c)
|
||||
puts(1,"a x (b x c) = ") ?vector_triple_product(a,b,c)
|
||||
Loading…
Add table
Add a link
Reference in a new issue