omer

0 Reputation

One Badge

19 years, 211 days

MaplePrimes Activity


These are answers submitted by omer

I rather use the construct    Matrix(m,n, proc(i,j)  statemets;  end proc);   to do this job easily.

Let  A ∈ ℝm×n   and  x ∈ ℝm  , WLOG for this example say that  A ∈ ℝ4×10  and  x ∈ ℝ4×1  and you want to substitute  x  with every 4th column of  A. But you want to do it in a generic way, regardless of the size of A (so it potentially be 4×1000 just as well).

Code

> m,n := op(A)[1 .. 2]
> Ax := Matrix(m, n, proc(i, j) if j mod 4 = 0 then x[i]; else A[i, j]; end if; end proc)

 

The result of summing the digits of a number is ever easily achieved with Maple, using two conversions:

  • The inner conversion, converts the number into a list of digits in a least significant to most significant order (see: ?convert[base] ) .
  • The outer conversion, converts the list into a sum (see: ?convert[`+`] )

Thereafter, the other procedure is applying the first recursively to the reduced form ...

 

f := proc (n::posint)::posint;
    convert(convert(n, base, 10), `+`);
end proc;


ReducedSum := proc (m::posint)::posint;
local n;
n := m;
    while 1 < length(n) do
        n := f(n);
    end do;
return(n);
end proc:

Hi All,

I have encountered this very basic problem and also been in contact with Maple's support and development about it.
There seems to be a bug in the way Maple is handling the element-wise comparison,  A =~ value, which fails SearchArray when the data type is not explicitly set to float.

The attached Maple Worksheet review the whole issue, including execution time.

The bad news are that Matlab is three orders of a magnitude faster because it returns the index value as it searches for the min / max.

It is SO SIMPLE to implement into the current min / max commands, I have put a request for modifying the command to a Matlab style return value (optional return assignement of course, so it is backwards compatible). If I be the only requester they probably do nothing about it, so rise your voice and make an opinion... I think it is important feature for a little modification, what do you think?

J

[Download this Maple Worksheet]

Page 1 of 1