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

## How to multiply two vectors??

Multiplication element by element:

Vanuxem Gregory replies:

Try

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

otherwise use Matrix:

fricas
a:= matrix [[1,2,3,4,5,6]]
 (3)
Type: Matrix(Integer)
fricas
a * transpose a
 (4)
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)
 (5)
Type: Vector(Integer)
fricas
v : VECTOR INT := vector([1,2,3])
 (6)
Type: Vector(Integer)
fricas
w : VECTOR INT := vector([2,3,4])
 (7)
Type: Vector(Integer)

multiply them

fricas
cross(v,w)
 (8)
Type: Vector(Integer)

dot product

fricas
dot(v,w)
 (9)
Type: PositiveInteger?

fricas
#(v)
 (10)
Type: PositiveInteger?

access an element

fricas
v(2)
 (11)
Type: PositiveInteger?

set an element

fricas
v(3) := 99
 (12)
Type: PositiveInteger?

show the vector

fricas
v
 (13)
Type: Vector(Integer)

multiply by a constant on either side

fricas
5 * v
 (14)
Type: Vector(Integer)
fricas
v * 7
 (15)
Type: Vector(Integer)

fricas
v + w
 (16)
Type: Vector(Integer)

substract them

fricas
v - w
 (17)
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.
74 Names for 95 Operations in this Domain.
------------------------------- 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                fill! : (%,Integer) -> %
first : % -> Integer                  hash : % -> SingleInteger
index? : (Integer,%) -> Boolean       indices : % -> List(Integer)
insert : (%,%,Integer) -> %           latex : % -> String
leftTrim : (%,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! : % -> %                     rightTrim : (%,Integer) -> %
sample : () -> %                      smaller? : (%,%) -> Boolean
sort : % -> %                         sort! : % -> %
sorted? : % -> Boolean                trim : (%,Integer) -> %
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)) -> %
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

 Subject:   Be Bold !! ( 15 subscribers )