help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: invertable matrix - result as integer matrix


From: Alasdair McAndrew
Subject: Re: invertable matrix - result as integer matrix
Date: Sun, 17 Jan 2010 23:40:36 +1100

It is indeed inversion modulo 26 that's required.  Here it is in Sage (http://www.sagemath,org):

sage: M=Matrix(Zmod(26),[[9,15],[19,2]])
sage: M^-1
 
[22 17]
[25 21]

I don't know if octave supports modular arithmetic, but to work with integers throughout, you would need to first calculate the adjoint of the matrix, multiply through by the modular inverse of the determinant (you may have to write your own program for this, using the extended Euclidean algorithm), and finally reduce every element modulo 26.

I would suggest that Octave may not be the best system for this purpose.

-Alasdair



On Sun, Jan 17, 2010 at 8:23 PM, Thomas Weber <address@hidden> wrote:
On Sun, Jan 17, 2010 at 06:50:36AM +0100, Jaroslav Hajek wrote:
> On Sun, Jan 17, 2010 at 1:47 AM, orzech <address@hidden> wrote:
> >
> > Hi,
> > I would like to get an invertible matrix in Octave but as integers matrix,
> > so:
> >
> > x = [9,15;19,2];
> > inv(x)
> >
> > and the result is:
> >
> > [-0.0074906, 0.0561798; 0.0711610, -0.0337079]
> >
> > but I would like to get [22,17;25,21] anyone knows how to convert this
> > result? Many thanks.
> >
>
> I don't understand:
> octave:7> [22,17;25,21] * [9,15;19,2]
> ans =
>
>    521   364
>    624   417
>
> this is clearly not remotely close to an inverse or its multiple.

I think orzech is calculating in the 26 residue class[1], i.e. Z/mZ with m=26.

mod(521,26) = 1;
mod(417,26) = 1;

mod(364,26) = 0;
mod(624,26) = 0;

[1] http://en.wikipedia.org/wiki/Modular_arithmetic

       Thomas
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave



--
Blog: http://amca01.wordpress.com
Web:  http://bit.ly/Alasdair
Facebook: http://www.facebook.com/alasdair.mcandrew

reply via email to

[Prev in Thread] Current Thread [Next in Thread]