What is a smart way to do this?
- To: mathgroup at smc.vnet.net
- Subject: [mg38881] What is a smart way to do this?
- From: nobody at this.org
- Date: Fri, 17 Jan 2003 05:38:39 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Dear Mathematica user, I have a very simple problem to solve, but no elegant solution for it. I deal with NxN matrices of integral entries where rows and columns are all proportional, e.g. for 3x3: ( 4 8 12 ) ( ) M = ( 5 10 15 ) ( ) ( 6 12 18 ) I need to decompose these matrices as a (Times) product: M = {{1,2,3},{1,2,3},{1,2,3}} * {{4,4,4},{5,5,5},{6,6,6}} there is no error: * is Times, not Dot. which I shall write M = {1,2,3}<*>{4,5,6} Finding the absolute values of components of the product M is easy, using Gcd on rows of M then of Transpose[M]. I MUST be blind, but what I don't see is how to restore correct signs efficiently without resorting to ugly code. For instance: ( -4 -8 12 ) ( ) M = ( 5 10 -15 ) ( ) ( 6 12 -18 ) M = {{1,2,-3},{1,2,-3},{1,2,-3}} * {{-4,-4,-4},{5,5,5},{6,6,6}} = {1,2,-3} <*> {-4,5,6} There always are two solutions with global sign change, since if M = u <*> v, then M = (-u) <*> (-v). Any of {u,v} or {-u,-v} will do. Shame on me for asking such an elementary question! Thank you.