Matrix in a program
|
10-27-2020, 02:28 AM
Post: #2
|
|||
|
|||
RE: Matrix in a program
(10-26-2020 10:21 PM)Tonig00 Wrote: When I tried to run it it gives me "Error: Invalid input". It does not work even with variables deleted. It just seems it did. Anyway, you should not do pivot on the variables. It make no sense. Some Issues: 1. SWAPROW(Ma1,r,n) does nothing. You have to save the returns. 2. pivot on 1 is preferred. But more importantly, pivot must be non-zero. 3. pivot row/col can only be used once. see Gauss Jordan Elimination Through Pivoting This is XCas implementation of revised code. note: XCas is setup 0-based, but POS returns 1-based (0 signals not found) Code: ImpGa(M, n) := { // pivot upto n columns XCas> M := [[1,2,x1],[2,1,x2],[0,1,x3],[1,2,x4],[3,-1,x5]] XCas> ImpGa(M, 2) \(\left(\begin{array}{ccc} 1 & 0 & \mathrm{x1}-2\cdot \mathrm{x3} \\ 0 & 1 & \mathrm{x3} \\ 0 & 0 & -2\cdot \mathrm{x1}+\mathrm{x2}+3\cdot \mathrm{x3} \\ 0 & 0 & -\mathrm{x1}+\mathrm{x4} \\ 0 & 0 & -3\cdot \mathrm{x1}+7\cdot \mathrm{x3}+\mathrm{x5} \end{array}\right) \) (10-27-2020 01:03 AM)Major Wrote: If you are wanting to use variables then I think it needs to be a CAS program instead of a Home program. Another way is replacing variables with an identity matrix. XCas> M := [[1,2],[2,1],[0,1],[1,2],[3,-1]] XCas> ImpGa(augment(M, identity(5)), 2) \(\left(\begin{array}{ccccccc} 1 & 0 & 1 & 0 & -2 & 0 & 0 \\ 0 & 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & -2 & 1 & 3 & 0 & 0 \\ 0 & 0 & -1 & 0 & 0 & 1 & 0 \\ 0 & 0 & -3 & 0 & 7 & 0 & 1 \end{array}\right) \) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Matrix in a program - Tonig00 - 10-26-2020, 10:21 PM
RE: Matrix in a program - Albert Chan - 10-27-2020 02:28 AM
RE: Matrix in a program - Tonig00 - 10-27-2020, 07:37 PM
RE: Matrix in a program - Tonig00 - 10-27-2020, 07:59 PM
|
User(s) browsing this thread: 1 Guest(s)