# Question:elementwise tilde operator in proc

## Question:elementwise tilde operator in proc

Maple

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

﻿