acer

32353 Reputation

29 Badges

19 years, 331 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

I understand the topology viewpoint.

But I am not happy with the mixed results. Neither am I thrilled with this:

> is( abs(x) < infinity );
                                     true

acer

That mechanism for setting compiler/linker flags for define_external (using that record like 'p') will do nothing for the Compiler.

Overriding the compiler/linker and flags for use by the Compiler is quite different. (I figured out a hack to accomplish it -- I'd have to find and dig it out...)

Instead, can you simply alias gcc='gcc -m32' in the linux shell from which you start Maple?

acer

You say that you are using 32bit Maple 12. And you have both 64bit and 32bit gcc compilers installed. Is the 32bit gcc the first one that will be found in the PATH that Maple sees?

Assuming that's the source of the problem, try appending the location of the 32bit gcc to be first in the PATH in a linux shell. Then start maple from there.

There is a way to force the Maple Compiler to use other values (CC, LDFLAGS, etc). But maybe this above is a simpler solution for your case.

acer

Yes, sure. I was trying (not very well) to preclude the need for all the details.

This one would have risked stirring that up again,

> simplify( signum(1,Q) ) assuming Q>0 or Q<0;
                                       0

acer

Yes, sure. I was trying (not very well) to preclude the need for all the details.

This one would have risked stirring that up again,

> simplify( signum(1,Q) ) assuming Q>0 or Q<0;
                                       0

acer

Eric, I suggest that you abandon using lists of lists for this. I would suggest using either an Array or a Matrix, and perhaps with float[8] datatype for maximal speed and minimal memory footprint.

For one thing, lists of lists are inherently bad for sorting, due to immutability. (Sorting lists of lists via attributes is neat, but the very fact that acrobatics are required makes it suspect.)

Extraction of columns or rows of a Matrix/Array is easy -- there are several nice ways and even nice syntax. If you sort a column, and store the permutations as a side-effect, then you can apply those permutations to all the Array/Matrix at once. There are easy ways to do that too, with nice syntax.

And, if the Array/Matrix is float[8] datatype then you can using Maple's Compiler on procedures that you write to do these tasks. Such a compiled routine could be the fastest approach.

Slicing an Array/Matrix (by sorted values in a named column, or not) is also very easy and relatively fast.

acer

Plimpton was a collector of ancient mathematical manuscripts, not a Babylonian mathematician. See here.

acer

As I mentioned, it matters whether the data are in lists, arrays, or Vectors. You have Cd as a list, and S and V as vectors (not Vectors).

Also, the names of the variables have to be names. You had them passed in as list and vectors.

> restart:

> Cd := Vector([.686, .693, .702, .714, .728, .745, .764,
> .785, .594, .597, .601, .607, .614, .621, .63, .641,
> .545, .546, .549, .553, .557, .562, .566, .574, .514,
> .515, .518, .52, .523, .526, .53, .535, .494, .495,
> .496, .498, .5, .503, .504, .505, .479, .48, .481, .482,
> .484, .485, .488, .49]):

> S := Vector(10^3*[.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, .5, 1,
> 1.5, 2, 2.5, 3, 3.5, 4, .5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
> .5, 1, 1.5, 2, 2.5, 3, 3.5, 4, .5, 1, 1.5, 2, 2.5, 3,
> 3.5, 4, .5, 1, 1.5, 2, 2.5, 3, 3.5, 4]):

> V := Vector([40, 40, 40, 40, 40, 40, 40, 40, 60, 60,
> 60, 60, 60, 60, 60, 60, 80, 80, 80, 80, 80, 80, 80, 80,
> 100, 100, 100, 100, 100, 100, 100, 100, 120, 120, 120,
> 120, 120, 120, 120, 120, 140, 140, 140, 140, 140, 140,
> 140, 140]):

> W := Statistics:-Fit(a+b*s+c*v+d*s^2+e*s*v+f*v^2,
>                      Matrix([S, V]), Cd, [s, v]);

W := 0.902488010204080870 + 0.0000229827097505673132 s
 
                                                         -8  2
     - 0.00678694515306121904 v + 0.172619047619042866 10   s
 
                              -6                                 2
     - 0.226020408163267168 10   s v + 0.0000278906249999999783 v

acer

As I mentioned, it matters whether the data are in lists, arrays, or Vectors. You have Cd as a list, and S and V as vectors (not Vectors).

Also, the names of the variables have to be names. You had them passed in as list and vectors.

> restart:

> Cd := Vector([.686, .693, .702, .714, .728, .745, .764,
> .785, .594, .597, .601, .607, .614, .621, .63, .641,
> .545, .546, .549, .553, .557, .562, .566, .574, .514,
> .515, .518, .52, .523, .526, .53, .535, .494, .495,
> .496, .498, .5, .503, .504, .505, .479, .48, .481, .482,
> .484, .485, .488, .49]):

> S := Vector(10^3*[.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, .5, 1,
> 1.5, 2, 2.5, 3, 3.5, 4, .5, 1, 1.5, 2, 2.5, 3, 3.5, 4,
> .5, 1, 1.5, 2, 2.5, 3, 3.5, 4, .5, 1, 1.5, 2, 2.5, 3,
> 3.5, 4, .5, 1, 1.5, 2, 2.5, 3, 3.5, 4]):

> V := Vector([40, 40, 40, 40, 40, 40, 40, 40, 60, 60,
> 60, 60, 60, 60, 60, 60, 80, 80, 80, 80, 80, 80, 80, 80,
> 100, 100, 100, 100, 100, 100, 100, 100, 120, 120, 120,
> 120, 120, 120, 120, 120, 140, 140, 140, 140, 140, 140,
> 140, 140]):

> W := Statistics:-Fit(a+b*s+c*v+d*s^2+e*s*v+f*v^2,
>                      Matrix([S, V]), Cd, [s, v]);

W := 0.902488010204080870 + 0.0000229827097505673132 s
 
                                                         -8  2
     - 0.00678694515306121904 v + 0.172619047619042866 10   s
 
                              -6                                 2
     - 0.226020408163267168 10   s v + 0.0000278906249999999783 v

acer

The help-page ?Fit says that the second argument, "X", should be the independent data. For several independent variables, that data should be in a Matrix.

As you had it originally, the x, y, and z data were all being supplied as separate arguments. So Maple was trying to interpret the z array as the fourth parameter which is supposed to be designate the names of the independent variables.

The solution is to combine x and y into that single Matrix of independent data. See my response above.

Double check that it is oriented correctly, with x and y as the two columns of the 48x2 Matrix. You mentioned that x and y were "arrays". How they may be joined, to make a single Matrix with x and y as the two columns, will differ according to whether x and y are lists, arrays, or Vectors. For example,

> x:=[a,b]: y:=[c,d]:
> Matrix([x,y])^%T;
                                   [a    c]
                                   [      ]
                                   [b    d]
 
> x:=array(1..2,[a,b]): y:=array(1..2,[c,d]):
> Matrix([[x],[y]])^%T;
                                   [a    c]
                                   [      ]
                                   [b    d]
 
> x:=Vector([a,b]): y:=Vector([c,d]):
> Matrix([x,y]);
                                   [a    c]
                                   [      ]
                                   [b    d]

acer

The help-page ?Fit says that the second argument, "X", should be the independent data. For several independent variables, that data should be in a Matrix.

As you had it originally, the x, y, and z data were all being supplied as separate arguments. So Maple was trying to interpret the z array as the fourth parameter which is supposed to be designate the names of the independent variables.

The solution is to combine x and y into that single Matrix of independent data. See my response above.

Double check that it is oriented correctly, with x and y as the two columns of the 48x2 Matrix. You mentioned that x and y were "arrays". How they may be joined, to make a single Matrix with x and y as the two columns, will differ according to whether x and y are lists, arrays, or Vectors. For example,

> x:=[a,b]: y:=[c,d]:
> Matrix([x,y])^%T;
                                   [a    c]
                                   [      ]
                                   [b    d]
 
> x:=array(1..2,[a,b]): y:=array(1..2,[c,d]):
> Matrix([[x],[y]])^%T;
                                   [a    c]
                                   [      ]
                                   [b    d]
 
> x:=Vector([a,b]): y:=Vector([c,d]):
> Matrix([x,y]);
                                   [a    c]
                                   [      ]
                                   [b    d]

acer

Sorry, I answered this out of order.

acer

Sorry, I answered this out of order.

acer

It's not a great improvement, as it just produces a piecewise of a comparison of piecewises. One could get similar behaviour with the more straightforward (original) application of `min` and the introduction of `unapply`. Ie,

> f1:=x->piecewise(x>0,cos(x),1);
                    f1 := x -> piecewise(0 < x, cos(x), 1)

> f2:=x->piecewise(x>0,sin(x),-1);
                    f2 := x -> piecewise(0 < x, sin(x), -1)

> f3:=unapply(min(f1(x),f2(x)),x);

   f3 := x -> min(piecewise(0 < x, cos(x), 1), piecewise(0 < x, sin(x), -1))
 
> f3(2);
                                    cos(2)

That seems just as easy as does the following, given that one started with a request about using `min`.

> f3:=unapply(piecewise(f1(x)<f2(x),f1(x),f2(x)),x);

f3 := x -> piecewise(
 
    piecewise(0 < x, cos(x), 1) < piecewise(0 < x, sin(x), -1),
 
    piecewise(0 < x, cos(x), 1), piecewise(0 < x, sin(x), -1))

> f3(2);
                                    cos(2)

The original poster might be satisfied with using `unapply` on the `min` call, without even any combining of piecewises at all.  Simply using `unapply` alone might serve all his needs.

What I am now wondering is whether one can get Maple to actually combine this slightly harder example (with sin and cos) into a single piecewise. Such a simplified result would evaluate faster, or be simpler to subsequently manipulate. Neither `combine`, `simplify`, or the undocumented PiecewiseTools:-Simplify managed it, for my example.

The combined, single piecewise would look like this,
> f4 := unapply(piecewise(x>0,min(sin(x),cos(x)),-1),x);

             f4 := x -> piecewise(0 < x, min(cos(x), sin(x)), -1)

acer

It also helps if the specific tasks in the "use cases" are not all chosen purely according to what the product creators can imagine. Having a really good mechanism by which users and potential users can provide input into the set of tasks is important.

acer

First 523 524 525 526 527 528 529 Last Page 525 of 592