Ronan

1311 Reputation

14 Badges

12 years, 309 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

I like the scrollable vectors up to a point. They seem to be unnecessarly width restricted. Is there any way to increase this? Could anything be added to the .ini file as the is an entry in there to disable them?

Also, if the command is entered again it is ok

I have a global matrix with a default value set in a module. I also need the inverse of the matrix. Can the module do this?  I don't really want to have to get routines to calculate the inverse every time they are called.

restart

``

TM := module () local invMetric; export foo, bar; global Metric;  Metric := Matrix(3, shape = symmetric, [[1, 0, 0], [0, 1, 0], [0, 0, 1]]); invMetric := LinearAlgebra:-MatrixInverse(rtable_eval(Metric, 'inplace')); foo := proc () print('Metric' = Metric) end proc; bar := proc () print('invMetric' = invMetric) end proc end module

_m2278573910560

(1)

TM:-foo()

Metric = Matrix(%id = 36893490426002737860)

(2)

TM:-bar()

invMetric = Matrix(%id = 36893490426002738460)

(3)

Metric := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -2})

Matrix(%id = 36893490426002715820)

(4)

TM:-foo()

Metric = Matrix(%id = 36893490426002715820)

(5)

TM:-bar()

invMetric = Matrix(%id = 36893490426002738460)

(6)

NULL

Download 2024-12-30_Q_Module_Global_and_Local.mw

I use this type ckect elsewhere inside a package and it works. I can't get it to work in a stand alone procedure.

This was originally provided by @acer (best answer) in this question Experimental format for projective vectors - MaplePrimes

restart

 

 

test:=proc(V::{And('Vector(1)',satisfies( v->type(v[1],'Vector[:-column](3)') ) ),
               And('Vector(1)',satisfies( v->type(v[1],'Vector[:-row](3)') ) )})
print("works",V);
end proc

proc (V::{And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-column](3)') end proc)), And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-row](3)') end proc))}) print("works", V) end proc

(1)

v1:=<[<1,3,2>]>;
v2:=<[<a|b|c>]>

Vector(1, {(1) = Vector(3, {(1) = 1, (2) = 3, (3) = 2})})

 

Vector[column](%id = 36893490573309309044)

(2)

test(v1)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector(3, [1,3,2])])

 

test(v2)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector[row](3, [a,b,c])])

 

whattype(v1)

Vector[column]

(3)

whattype(v1[1])

Vector[column]

(4)

whattype(v2)

Vector[column]

(5)

whattype(v2[1])

Vector[row]

(6)
 

 

Download 2024-12-29_Q_Type_checking_not_working.mw

I am looking for a more eligent way to convert a Vector to a Diagonal Matrix.

restart

 

 

with(LinearAlgebra):

 

V:=Vector[column](3, [0.5863730366, 0.1171249270, 0.2965020364])

Vector(3, {(1) = .5863730366, (2) = .1171249270, (3) = .2965020364})

(1)

Vm:=Matrix(3,[[V[1],0,0],[0,V[2],0],[0,0,V[3]]])

Matrix(3, 3, {(1, 1) = .5863730366, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = .1171249270, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = .2965020364})

(2)

Vm1:=Matrix(3,3):

for i to 3 do
Vm1[i,i]:=V[i];
end do:

Vm1

Matrix(3, 3, {(1, 1) = .5863730366, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = .1171249270, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = .2965020364})

(3)
 

 

Download 2024-12-26_Q_Diagonal_Matrix_from_Vector.mw

I knowI can use a loop but I would like something neater. igcd can be applied to a list. Is there a way to map or use @ to apply gcd to a list?

lst:= [4, 2, 8, 4];
lst1 := [a^3/10, -a^2/2, a, a^4/4]
                      lst := [4, 2, 8, 4]

                        [1   3    1  2     1  4]
                lst1 := [-- a , - - a , a, - a ]
                        [10       2        4   ]


gd:=igcd(lst);



                            gd := 2

gd1=(gcd@op)(lst1);

 

1 2 3 4 5 6 7 Last Page 1 of 35