How to multiply two vectors??
Multiplication element by element:
Vanuxem Gregory replies:
Try
fricas
a:= vector [1,2,3,5,6]
Type: Vector(PositiveInteger
?)
fricas
map(*,a,a)
Type: Vector(PositiveInteger
?)
otherwise use Matrix:
fricas
a:= matrix [[1,2,3,4,5,6]]
Type: Matrix(Integer)
fricas
a * transpose a
Type: Matrix(Integer)
Tim Daly replies:
make three vectors
fricas
)clear all
All user variables and function definitions have been cleared.
u : VECTOR INT := new(5,12)
Type: Vector(Integer)
fricas
v : VECTOR INT := vector([1,2,3])
Type: Vector(Integer)
fricas
w : VECTOR INT := vector([2,3,4])
Type: Vector(Integer)
multiply them
fricas
cross(v,w)
Type: Vector(Integer)
dot product
fricas
dot(v,w)
ask for the length
fricas
#(v)
access an element
fricas
v.2
set an element
fricas
v.3 := 99
show the vector
fricas
v
Type: Vector(Integer)
multiply by a constant
on either side
fricas
5 * v
Type: Vector(Integer)
fricas
v * 7
Type: Vector(Integer)
add them
fricas
v + w
Type: Vector(Integer)
substract them
fricas
v - w
Type: Vector(Integer)
display all possible functions
fricas
)show Vector(Integer)
Vector(Integer) is a domain constructor.
Abbreviation for Vector is VECTOR
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
#? : % -> NonNegativeInteger ?*? : (Integer,%) -> %
?*? : (%,Integer) -> % ?+? : (%,%) -> %
?-? : (%,%) -> % -? : % -> %
?<? : (%,%) -> Boolean ?<=? : (%,%) -> Boolean
?=? : (%,%) -> Boolean ?>? : (%,%) -> Boolean
?>=? : (%,%) -> Boolean coerce : % -> OutputForm
concat : (Integer,%) -> % concat : List(%) -> %
concat : (%,Integer) -> % concat : (%,%) -> %
construct : List(Integer) -> % convert : % -> InputForm
copy : % -> % copyInto! : (%,%,Integer) -> %
cross : (%,%) -> % delete : (%,Integer) -> %
dot : (%,%) -> Integer ?.? : (%,Integer) -> Integer
empty : () -> % empty? : % -> Boolean
entries : % -> List(Integer) entry? : (Integer,%) -> Boolean
eq? : (%,%) -> Boolean eval : (%,Integer,Integer) -> %
fill! : (%,Integer) -> % first : % -> Integer
hash : % -> SingleInteger index? : (Integer,%) -> Boolean
indices : % -> List(Integer) insert : (%,%,Integer) -> %
latex : % -> String length : % -> Integer
magnitude : % -> Integer max : (%,%) -> %
maxIndex : % -> Integer member? : (Integer,%) -> Boolean
members : % -> List(Integer) merge : (%,%) -> %
min : (%,%) -> % minIndex : % -> Integer
parts : % -> List(Integer) position : (Integer,%) -> Integer
qelt : (%,Integer) -> Integer remove : (Integer,%) -> %
removeDuplicates : % -> % reverse : % -> %
reverse! : % -> % sample : () -> %
smaller? : (%,%) -> Boolean sort : % -> %
sort! : % -> % sorted? : % -> Boolean
vector : List(Integer) -> % zero : NonNegativeInteger -> %
zero? : % -> Boolean ?~=? : (%,%) -> Boolean
any? : ((Integer -> Boolean),%) -> Boolean
count : (Integer,%) -> NonNegativeInteger
count : ((Integer -> Boolean),%) -> NonNegativeInteger
delete : (%,UniversalSegment(Integer)) -> %
elt : (%,Integer,Integer) -> Integer
?.? : (%,UniversalSegment(Integer)) -> %
eval : (%,Equation(Integer)) -> %
eval : (%,List(Equation(Integer))) -> %
eval : (%,List(Integer),List(Integer)) -> %
every? : ((Integer -> Boolean),%) -> Boolean
find : ((Integer -> Boolean),%) -> Union(Integer,"failed")
hashUpdate! : (HashState,%) -> HashState
insert : (Integer,%,Integer) -> %
less? : (%,NonNegativeInteger) -> Boolean
map : (((Integer,Integer) -> Integer),%,%) -> %
map : ((Integer -> Integer),%) -> %
map! : ((Integer -> Integer),%) -> %
merge : (((Integer,Integer) -> Boolean),%,%) -> %
more? : (%,NonNegativeInteger) -> Boolean
new : (NonNegativeInteger,Integer) -> %
outerProduct : (%,%) -> Matrix(Integer)
position : (Integer,%,Integer) -> Integer
position : ((Integer -> Boolean),%) -> Integer
qsetelt! : (%,Integer,Integer) -> Integer
reduce : (((Integer,Integer) -> Integer),%,Integer,Integer) -> Integer
reduce : (((Integer,Integer) -> Integer),%,Integer) -> Integer
reduce : (((Integer,Integer) -> Integer),%) -> Integer
remove : ((Integer -> Boolean),%) -> %
select : ((Integer -> Boolean),%) -> %
setelt : (%,Integer,Integer) -> Integer
setelt : (%,UniversalSegment(Integer),Integer) -> Integer
size? : (%,NonNegativeInteger) -> Boolean
sort : (((Integer,Integer) -> Boolean),%) -> %
sort! : (((Integer,Integer) -> Boolean),%) -> %
sorted? : (((Integer,Integer) -> Boolean),%) -> Boolean
swap! : (%,Integer,Integer) -> Void