Inverse of 3x3 Matrix with Complex Numbers
|
07-15-2019, 11:59 AM
Post: #1
|
|||
|
|||
Inverse of 3x3 Matrix with Complex Numbers
Hello!
My next calculator should be able to work with 3x3 matrices with complex numbers (determinant, invert, add, substract, multiply, ...). That for I want to impement fast explicit formulae (found on Wikipedia) rather than some algorithms. The calculator itself works with two double stacks for real and imaginary parts of numbers (stack[4] and stacki[4]). Basic stack operations are done with _add(), _sub() and _mult(). For matrix operations I use matrix A (ma[3][3] and mai[3][3]) and B (mb[3][3] and mbi[3][3]) and a temporary matrix C (mc[3][3] and mci[3][3]). So far I implemented the following code which works fine: Code: static void _mdet(void) { // MATRIX DET A Unfortunately this code "eats up" (too) many valuable bytes. I'm sure it can be optimized and shrinked - at least with some loops. But I must resign to manage such loop indices. Does anyone of you (very smart guys) see how to automate this code in an efficient way? Any idea and hint is highly welcome. Regards deetee |
|||
07-16-2019, 05:47 AM
(This post was last modified: 07-16-2019 05:48 AM by deetee.)
Post: #2
|
|||
|
|||
RE: Inverse of 3x3 Matrix with Complex Numbers
Hi!
At least I found some improvement by myself to reduce the code size by summarizing similar code in subroutines - and call them with (a lot of) index parameters: Code: static void _mdetrc(byte r1, byte r2, byte r3, byte c1, byte c2, byte c3, int8_t mult) { Thanks in advance for any hint. Regards deetee |
|||
07-16-2019, 10:34 AM
Post: #3
|
|||
|
|||
RE: Inverse of 3x3 Matrix with Complex Numbers
(07-16-2019 05:47 AM)deetee Wrote: Hi! Have you benchmarked your routine vs. the built-in routines? I'd be curious to see if there's a significant difference one way or the other. Tom L Cui bono? |
|||
07-16-2019, 12:07 PM
(This post was last modified: 07-16-2019 12:11 PM by deetee.)
Post: #4
|
|||
|
|||
RE: Inverse of 3x3 Matrix with Complex Numbers
Hi Tom!
No I didn't benchmark the explicit method and an algorithm based method, but I think the explicit method is much faster. On my Arduino (ATMEGA328P) the result was shown immediately. On the other hand algorithms are more flexible regarding the (matrix) dimensions. My intention was to solve matrices with complex numbers up to 3x3. The input of 9 complex numbers is quite painful. For bigger dimensions one should rather use a PC. Regards deetee PS: BTW I'm not using an existing calculator. I try to build my own hardware. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)