Help: Port prg to Home Mode( Minor linear_algebra)
|
02-02-2014, 11:43 PM
(This post was last modified: 02-10-2014 02:09 PM by compsystems.)
Post: #1
|
|||
|
|||
Help: Port prg to Home Mode( Minor linear_algebra)
http://en.wikipedia.org/wiki/Minor_(linear_algebra)
ENTRY LINE EDITON Code: minor_CAS0(m1):= then minor_CAS0([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns [[-3,-6,-3], [-6,-12,-6], [-3,-6,-3]] OK ////// but HOME MODE PRG EDITOR Code: EXPORT minor_HOME0(m1) minorHOME([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns "Error: Bad Argument Type" ???? |
|||
02-03-2014, 05:38 AM
Post: #2
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
Why are you defining j and ii as strings? Also, the help for DELCOL() and DELROW() suggest that they modify the matrix itself, so that subsequent references to the matrix are actually references to the the modified version.
To see this for yourself: Code:
My guess is that in CAS mode the dummy variable somehow protects its contents to prevent DELCOL() and DELROW() from modifying the matrix. Either that, or it is a bug. The commands you should probably be using instead: delcols() and delrows() -- these do not alter the matrix. Code:
You can easily change this to use seq() if you prefer. Just don't confuse a sequence with a matrix even if they both use the same delimiters. Graph 3D | QPI | SolveSys |
|||
02-03-2014, 03:06 PM
(This post was last modified: 02-03-2014 03:44 PM by compsystems.)
Post: #3
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
sorry for my bad English
The version in CAS mode works fine, but not in HOME mode =(, but as there is not a program editor for cas mode my calculator this underutilized. Han: Why are you defining j and ii as strings? I try to do the trick you discussed in another topic. http://www.hpmuseum.org/forum/thread-538.html Code: export convolution1(v1,v2) Han: Just don't confuse a sequence with a matrix even if they both use the same delimiters. the seq command generates a one-dimensional array, and seq (seq generates a two-dimensional array seq(x²,x,1,3); enter returns [1,4,9]; TYPE(Ans); returns 4 (Matrix 1x3) best vector =) seq(seq(x²,x,1,3),x,1,2); enter returns [[1,1,1], [4,4,4]]; TYPE(Ans); returns 4 (Matrix 2x3) Using the seq cmd, number of instructions is reduced =) Code: minorCAS2(m1):= minorCAS2([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns [[-3,-6, -3] [-6,-12,-6] [-3,-6, -3]] OK Smile versus your code Code: EXPORT MINOR(m) MINOR([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns {-3,-6,-3,-6,-12,-6,-3,-6,-3} LIST http://www.maplesoft.com/support/help/Ma...ebra/Minor |
|||
02-03-2014, 07:22 PM
(This post was last modified: 02-04-2014 03:27 AM by Han.)
Post: #4
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
Quote:Using the seq cmd, number of instructions is reduced =) That may be true, but sometimes it is beneficial to separate your commands. For example, using coldim() inside the seq() command means coldim() is computed repeatedly -- which is unnecessary, and slow if you have a much larger matrix. If you precompute the dimensions, then the seq() command would only be reading a value as opposed to calculating it every iteration. Secondly, separating the commands makes debugging much easier. As for list vs matrix, try: Code:
Graph 3D | QPI | SolveSys |
|||
02-09-2014, 03:15 PM
(This post was last modified: 02-09-2014 03:29 PM by compsystems.)
Post: #5
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
Code:
MINOR_HOME1([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns [[-3,-6, -3] [-6,-12,-6] [-3,-6, -3]] OK Code:
MINOR_CAS1([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns ??? {{"Error: Bad Argument Type","Error: Bad Argument Type","Error: Bad Argument Type"}, {"Error: Bad Argument Type","Error: Bad Argument Type","Error: Bad Argument Type"}, {"Error: Bad Argument Type","Error: Bad Argument Type","Error: Bad Argument Type"}} Code:
MINOR_CAS0([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns [[-3,-6, -3] [-6,-12,-6] [-3,-6, -3]] OK |
|||
02-09-2014, 03:26 PM
(This post was last modified: 02-09-2014 03:29 PM by Han.)
Post: #6
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
MAKEMAT() and makemat() are two different commands.
MAKEMAT(expr, m, n): MAKEMAT(I^2+J, 3, 5); makemat(func, m, n): makemat( (x,y)->x^2+y, 3, 5); Is there any reason to insist on using a CAS program instead of a regular program? Graph 3D | QPI | SolveSys |
|||
02-09-2014, 03:55 PM
(This post was last modified: 02-09-2014 09:25 PM by compsystems.)
Post: #7
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
now with MAKEMAT on CAS MODE fail Why?
Code:
MINOR_CAS2([[1,2,3],[4,5,6],[7,8,9]]); [enter] returns "Error: Bad Argument Type ?? Quote:Han: MAKEMAT() and makemat() are two different commands. >> On HOME mode MAKEMAT() and makemat() are equal I: HOME MODE INDEX = (1,1) for MAKEMAT or makemat or makeMat or or any combination of uppercase and lowercase MAKEMAT(I^2+J,3,5); // HOME MODE => [[2,3,4,5,6], [5,6,7,8,9], [10,11,12,13,14]] OK makemat(I^2+J,3,5); makeMat(I^2+J,3,5); => MAKEMAT(I^2+J,3,5); // HOME MODE => [[2,3,4,5,6], [5,6,7,8,9], [10,11,12,13,14]] OK INDEX = (1,1) step1: I=1, J=1,..,5 1^2+1=2, 1^2+2=3, 1^2+3=4, 1^2+4=5, 1^2+5=6 // ok step2: I=2, J=1,..,5 2^2+1=5, 2^2+2=6, 2^2+3=7, 2^2+4=8, 2^2+5=9 // ok step3: I=3, J=1,..,5 3^2+1=10, 3^2+2=11, 3^2+3=12, 3^2+4=13, 3^2+5=14 // ok MAKEMAT((I,J)->I²+J,3,5); or makemat((I,J)->I²+J,3,5); "Error: Syntax Error" /////////////// On CAS mode MAKEMAT() and makemat() are not equal =) Support catalog says nothing about this =( Quote:Han: Is there any reason to insist on using a CAS program instead of a regular program? Muchas, una de ellas es que algunos comandos se comportan diferente. entonces se puede aprovechar esta característica dentro de un programa, otra permite una mas fácil manipulación de expresiones simbolicas MAKEMAT en CAS MODE opera en índice (0,0) =) INDEX = (0,0) for makemat and INDEX = (1,1) for MAKEMAT makemat( (I,J)->I²+J, 3,5); // CAS MODE => [[0,1,2,3,4], [1,2,3,4,5], [4,5,6,7,8]] OK step1: I=0 J=0,..,4 0^2+0=0, 0^2+1=1, 0^2+2=2, 0^2+3=3, 0^2+4=4 // ok step2: I=1, J=0,..,4 1^2+0=1, 1^2+1=2, 1^2+2=3, 1^2+3=4, 1^2+5=6 // ok step3: I=2, J=0,..,4 2^2+0=4, 2^2+1=5, 2^2+2=6, 2^2+3=7, 2^2+4=8 // ok INDEX = (1,1) for MAKEMAT MAKEMAT(I²+J,3,5); // CAS MODE => [[2,3,4,5,6], [5,6,7,8,9], [10,11,12,13,14]] OK BUT MAKEMAT((I,J)->I²+J,3,5); // CAS MODE => Bug because should return only the right evaluation of the function [[(1,1)->1²+1,(1,2)->1²+2,(1,3)->1²+3,(1,4)->1²+4,(1,5)->1²+5], [(2,1)->2²+1,(2,2)->2²+2,(2,3)->2²+3,(2,4)->2²+4,(2,5)->2²+5], [(3,1)->3²+1,(3,2)->3²+2,(3,3)->3²+3,(3,4)->3²+4,(3,5)->3²+5]] =( F1(I,J):=I^2+J; returns F1:=(I,J)->I²+J => (I,J)->I²+J makemat(F1(I,J),3,5) // CAS MODE or MAKEMAT(F1(I,J),3,5) // CAS MODE => Not operate, why? BUG? "makemat(F1(I,J),3,5) Error: Bad Argument Value" ... makeMat(I²+J,3,5); [[0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] ??? makeMat((I,J)->I²+J,3,5); "Error: Unmatch control word" ?? /// Han can you port the following code to HOME MODE Code: // Code on CAS MODE OK, HOME MODE =( with simplify NONE (CAS Settings), collectPolTerms_CAS0(((-3*a*x²+7*a*x^1-2*a-3*b*x²+7*b*x^1-2*b+3*x^3-7*x²+2*x^1)/3),x); [ENTER} returns x^3+((-3*a-3*b-7)/3)*x²+((7*a+7*b+2)/3)*x+(-2*a-2*b)/3 OK Thanks |
|||
02-09-2014, 05:35 PM
(This post was last modified: 02-09-2014 05:37 PM by Han.)
Post: #8
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
(02-09-2014 03:55 PM)compsystems Wrote: >> On HOME mode MAKEMAT() and makemat() are equal That is because Home view does not distinguish upper case from lower case. Home view is not aware of CAS commands (generally speaking; there are a few CAS commands that still work in Home because they have been implemented for Home). CAS commands will sometimes work (in lower case) but generally require the CAS.command() format. So MAKEMAT() and makemat() are the same in Home, but CAS.makemat() is different. Quote:On CAS mode MAKEMAT() and makemat() are not equal =) Correct. Quote:Support catalog says nothing about this =( Unfortunately, the catalog is missing a LOT of information. Quote:MAKEMAT en CAS MODE opera en índice (0,0) =) Don't mix commands and syntax. You are using MAKEMAT() but you are trying to incorporate the syntax of the other command: makemat(). MAKEMAT() is working exactly as you told it to. When you use the (I,J)->I^2+J syntax, MAKEMAT() -- because it is NOT a CAS command -- has no idea about the meaning of (var)->expr because that is a CAS syntax. Instead, MAKEMAT treats (I,J)->I^2+J as an expression and substitutes values of I and J in, and simplifies as best it can. Quote:F1(I,J):=I^2+J Because the first argument of makemat() -- which is a CAS command -- requires a function. So either use F1 by itself, or use (I,J)->I^2+J. When you used F1(I,J), then this is an evaluation of a function, which produces a expression. Quote:makeMat(I²+J,3,5); Here I and J are constants -- 0. The command line interpreted "makeMat" as "makemat" so that you are just requesting a 3x5 matrix with 0 as the entry. Quote:/// There is nothing required for porting. If you want to use that command in Home, just put your arguments as strings. So in Home view, do: collectPolTerms_CAS0("((-3*a*x²+7*a*x^1-2*a-3*b*x²+7*b*x^1-2*b+3*x^3-7*x²+2*x^1)/3)","x") Graph 3D | QPI | SolveSys |
|||
02-09-2014, 08:26 PM
(This post was last modified: 02-09-2014 09:22 PM by compsystems.)
Post: #9
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
abstract
for HOME MODE MAKEMAT(expresion/expresion(I,J), m, n) or makemat(expresion/expresion(I,J), m, n) or makeMAT(expresion/expresion(I,J), m, n) with INITIAL INDEX (I=1,J=1) example with expresion MAKEMAT(X+2, 3, 5); or makeMat(X+2, 3, 5); => [[2,2,2,2,2], [2,2,2,2,2], [2,2,2,2,2]] OK, with the current value of X (by default 0) MAKEMAT(X^2+Y, 3, 5); or makeMat(X^2+Y, 3, 5); => [[0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] OK, with the current value of X, Y (by default 0) with expresion(I,J) MAKEMAT(I^2+J, 3, 5); or makeMat(I^2+J, 3, 5); => [[2,3,4,5,6], [5,6,7,8,9], [10,11,12,13,14]] OK with function MAKEMAT((I,J)->I²+J,3,5); or makemat((I,J)->I²+J,3,5); "Error: Syntax Error" OK //////////// for CAS MODE with uppercase and expresion(I,J) MAKEMAT(I^2+J, 3, 5); // INITIAL INDEX (I=0,J=0) [[2,3,4,5,6], [5,6,7,8,9], [10,11,12,13,14]] OK another expresion MAKEMAT(Ii^2+Ee, 3, 5); [[Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee], [Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee], [Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee]] OK lowercase makemat( function(I,J), m, n) with INITIAL INDEX (I=1,J=1) example makemat( (I,J)->I²+J, 3,5); => [[0,1,2,3,4], [1,2,3,4,5], [4,5,6,7,8]] OK makemat((X,Y)->X²+Y,3,5); => [[0,1,2,3,4], [1,2,3,4,5], [4,5,6,7,8]] OK Code: Han: interpreted "makeMat" as "makemat" makeMat((I,J)->I²+J,3,5); => "Error: Unmatch control word" ?? ////// with expresión makemat(Ii^2+Ee, 3, 5); [[Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee], [Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee], [Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee,Ii²+Ee]] OK makemat(I^2+J, 3, 5); [[0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] OK // I and J with the current value of I, J (default 0) //// Quote:Han: There is nothing required for porting. Code:
help "Error Syntax on k" =( |
|||
02-10-2014, 03:53 AM
(This post was last modified: 02-10-2014 03:54 AM by Han.)
Post: #10
|
|||
|
|||
RE: Help HOME PRG (Minor linear_algebra)
(02-09-2014 08:26 PM)compsystems Wrote: abstract There is only one command in Home mode no matter how you type it, it will get parsed as MAKEMAT(). If you want to use the CAS command in Home, the only way to do so is use CAS.makemat(). Quote:for CAS MODE This is incorrect. MAKEMAT() is the non-CAS command and its index starts at 1 for I and J. Quote:lowercase Incorrect. The index for the CAS command makemat() starts at 0. Quote: This is a mistake on my part (a typo). "makeMat" is parsed as "MAKEMAT." However, due to the fact that we are typing this from the CAS view, the command line tries to parse it in a way that Home would expect (because MAKEMAT is not a CAS command). Thus, all variables within the argument are resolved first. If they cannot be resolved, this generates an error. (This is either a bug, or a poor design choice.) Anyway, the code Code: makeMat((I,J)->I²+J,3,5); => "Error: Unmatch control word" ?? cannot work for two reasons: 1. makeMat is parsed as MAKEMAT (so that the functional expression is invalid) 2. in an attempt to resolve the variables in the expression (I,J)->I^2+J would result in an invalid argument Quote:Han: There is nothing required for porting. I will have to look into this more carefully as I overlooked the variable k the first time. Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)