login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for Computing with Vectors revision 1 of 4

1 2 3 4
Editor: 127.0.0.1
Time: 2007/11/15 20:28:02 GMT-8
Note: transferred from axiom-developer

changed:
-
How to multiply two vectors??

  Multiplication element by element:

*Vanuxem Grégory replies:*
\begin{axiom}
a:= vector [1,2,3,5,6]
map(*,a,a)
\end{axiom}

otherwise use Matrix:
\begin{axiom}
a:= matrix [[1,2,3,4,5,6]]
a * transpose a
\end{axiom}

Tim Daly replies:

make three vectors
\begin{axiom}
)clear all
u : VECTOR INT := new(5,12)
v : VECTOR INT := vector([1,2,3])
w : VECTOR INT := vector([2,3,4])
\end{axiom}
multiply them
\begin{axiom}
cross(v,w)
\end{axiom}
dot product
\begin{axiom}
dot(v,w)
\end{axiom}
ask for the length
\begin{axiom}
#(v)
\end{axiom}
access an element
\begin{axiom}
v.2
\end{axiom}
set an element
\begin{axiom}
v.3 := 99
\end{axiom}
show the vector
\begin{axiom}
v
\end{axiom}
multiply by a constant
on either side
\begin{axiom}
5 * v
v * 7
\end{axiom}

add them
\begin{axiom}
v + w
\end{axiom}

substract them
\begin{axiom}
v - w
\end{axiom}

display all possible functions
\begin{axiom}
)show Vector(Integer)
\end{axiom}

How to multiply two vectors??

Multiplication element by element:

*Vanuxem Grégory replies:*

axiom
a:= vector [1,2,3,5,6]
LatexWiki Image(1)
Type: Vector PositiveInteger?
axiom
map(*,a,a)
LatexWiki Image(2)
Type: Vector PositiveInteger?

otherwise use Matrix:

axiom
a:= matrix [[1,2,3,4,5,6]]
LatexWiki Image(3)
Type: Matrix Integer
axiom
a * transpose a
LatexWiki Image(4)
Type: Matrix Integer

Tim Daly replies:

make three vectors

axiom
)clear all All user variables and function definitions have been cleared. u : VECTOR INT := new(5,12)
LatexWiki Image(5)
Type: Vector Integer
axiom
v : VECTOR INT := vector([1,2,3])
LatexWiki Image(6)
Type: Vector Integer
axiom
w : VECTOR INT := vector([2,3,4])
LatexWiki Image(7)
Type: Vector Integer

multiply them

axiom
cross(v,w)
LatexWiki Image(8)
Type: Vector Integer

dot product

axiom
dot(v,w)
LatexWiki Image(9)
Type: PositiveInteger?

ask for the length

axiom
#(v)
LatexWiki Image(10)
Type: PositiveInteger?

access an element

axiom
v.2
LatexWiki Image(11)
Type: PositiveInteger?

set an element

axiom
v.3 := 99
LatexWiki Image(12)
Type: PositiveInteger?

show the vector

axiom
v
LatexWiki Image(13)
Type: Vector Integer

multiply by a constant on either side

axiom
5 * v
LatexWiki Image(14)
Type: Vector Integer
axiom
v * 7
LatexWiki Image(15)
Type: Vector Integer

add them

axiom
v + w
LatexWiki Image(16)
Type: Vector Integer

substract them

axiom
v - w
LatexWiki Image(17)
Type: Vector Integer

display all possible functions

axiom
)show Vector(Integer) Vector Integer is a domain constructor. Abbreviation for Vector is VECTOR This constructor is exposed in this frame. Issue )edit /usr/local/lib/axiom/target/x86_64-unknown-linux/../../src/algebra/VECTOR.spad to see algebra source code for VECTOR ------------------------------- 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 : (%,Equation Integer) -> % 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 : () -> % sort : % -> % sort! : % -> % sorted? : % -> Boolean vector : List Integer -> % zero : NonNegativeInteger -> % ?~=? : (%,%) -> Boolean any? : ((Integer -> Boolean),%) -> Boolean count : (Integer,%) -> NonNegativeInteger count : ((Integer -> Boolean),%) -> NonNegativeInteger delete : (%,UniversalSegment Integer) -> % elt : (%,Integer,Integer) -> Integer ?.? : (%,UniversalSegment Integer) -> % eval : (%,List Equation Integer) -> % eval : (%,List Integer,List Integer) -> % every? : ((Integer -> Boolean),%) -> Boolean find : ((Integer -> Boolean),%) -> Union(Integer,"failed") 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