Harry Garst

219 Reputation

5 Badges

16 years, 337 days

MaplePrimes Activity


These are questions asked by Harry Garst

I can't find in the Linear Algebra package the command for creating the duplication matrix.

The duplication matrix is the n * n rows and n * ( n + 1 ) / 2 columns that transforms vech(A)
to vec(A) where A is a symmetric n by n matrix (Magnus & Neudecker).

If it not yet in Maple itself, has someone already made a proc for it?

Harry Garst

 

 

For many years I succesfully used the command:

Lambda := ImportMatrix(LambdaFile, delimiter = "", datatype = string);

 

but for some txt files I now got the following error in Maple 2016:
Error, (in ImportMatrix) cannot interpret file

The same code still runs without problems at all in previous versions of Maple.

The strange thing is that other txt files can be still be imported in Maple 2016 without problems.

I will upload two files:

ULSlx3.txt returns an error message

ULStd3.txt no problems

ULSlx3.txt

ULStd3.txt

complete code:

restart;
with(LinearAlgebra); with(Statistics);
interface(rtablesize = infinity);
with(Typesetting):
interface(typesetting=extended):

LambdaFile := "C:/path/ULSlx3.txt";
Lambda := Matrix(5, 1);

in the whatsnew there is no information on changes with respect to the ImportMatrix command, although there is some (unrelated) information on Importing Data:

Importing Data
By default, the Import command now returns a DataFrame when importing from Excel, CSV, DIF, and TSV file formats, and returns a DataSeries when importing from ODS, SXC, and TSV file formats. Use the output option to specify a different format. For example, Import(origin, output=Matrix).

 

I have no clue what is wrong with my code and why some text files can be imported as before whereas other files returns an error message.

greetings Harry

I hoped that Maple would return the value of 1 in all commands (see below). However, introducing a scaling parameter, sigma, yields the unevaluated expression. Why? I still think it should evaluate to the value of 1.

 

kind regards,

Harry (not a mathematician, but a psychologist)

 

 

 

integral.mw

 

After reading 

http://math.stackexchange.com/questions/674535/avoid-dividing-by-zero-with-just-variables-and-basic-operators 

I tried to check this 'trick' in maple, but see what happens in Maple 2015:

 

 

 what is the correct solution for 0^0?

 

Here the code for those who hate typing:

x := 0; 0^(x^2);
0
1
for x from -1 to 1 do print(x, evalf(0^(x^2), 20)) end do;
-1, 0.
0, 1.
1, 0.
for x from -1 by .1 to 1 do print(x, evalf(0^(x^2), 20)) end do;
-1, 0.
-0.9, 0.
-0.8, 0.
-0.7, 0.
-0.6, 0.
-0.5, 0.
-0.4, 0.
-0.3, 0.
-0.2, 0.
-0.1, 0.
0., Float(undefined)
0.1, 0.
0.2, 0.
0.3, 0.

 

Harry

The following code works fine:

restart;
with(LinearAlgebra): with(MTM): with(StringTools): MultivariateNormalSample := proc (Sigma, V, N) local d; d := LinearAlgebra:-Dimension(V); LinearAlgebra:-LUDecomposition(Matrix(Sigma, datatype = float[8]), 'method' = 'Cholesky') . ArrayTools:-Alias(Statistics:-Sample(Normal(0, 1), d*N), [d, N])+ArrayTools:-Replicate(Vector[column](V, datatype = float[8]), 1, N) end proc: S := MultivariateNormalSample(`<,>`(`<|>`(1, 2), `<|>`(2, 5)), `<,>`(2, 3), 100):
W := ~int8(~round(S)):
K := convert(W, string):
K := Drop(K, 17):
K := Select(IsDigit, K):
M := seq(PadRight(K[i], 2), i = 1 .. Length(K)):
Z := M[1]:
for i from 2 to Length(K) do Z := cat(Z, M[i]); if `mod`(i, 2) = 0 then Z := cat(Z, "\n") end if end do:
Z;

but if I make a proc out of it then it breaks down on the line:

 W := ~int8(~round(S)):

There seems to be an issue with the elementwise tilde operator.

restart;
Generate:=proc()
local MultivariateNormalSample,S,W,K,M,Z,i;
with(LinearAlgebra): with(MTM): with(StringTools):
MultivariateNormalSample := proc (Sigma, V, N) local d; d := LinearAlgebra:-Dimension(V); LinearAlgebra:-LUDecomposition(Matrix(Sigma, datatype = float[8]), 'method' = 'Cholesky') . ArrayTools:-Alias(Statistics:-Sample(Normal(0, 1), d*N), [d, N])+ArrayTools:-Replicate(Vector[column](V, datatype = float[8]), 1, N) end proc: S := MultivariateNormalSample(`<,>`(`<|>`(1, 2), `<|>`(2, 5)), `<,>`(2, 3), 100):
W := ~int8(~round(S)):
K := convert(W, string):
K := Drop(K, 17):
K := Select(IsDigit, K):
M := seq(PadRight(K[i], 2), i = 1 .. Length(K)):
Z := M[1]:
for i from 2 to Length(K) do Z := cat(Z, M[i]); if `mod`(i, 2) = 0 then Z := cat(Z, "\n") end if end do:
return Z:
end proc;Generate();

I seem to have missed something. Any ideas?

Harry

3 4 5 6 7 8 9 Page 5 of 10