Resubmitting legacy RCR 161

Discussion in 'Ruby' started by M. Edward (Ed) Borasky, Aug 6, 2006.

  1. Some time back, RCR 161 was submitted to add a []= method to the Matrix
    class defined in "matrix.rb". Apparently, this was imported from an
    older database and needs to be resubmitted. Can "anyone" (for example,
    me) do that, or does it have to be the original submitter?

    I took a look at the code and I can't imagine what having that method
    would break -- I was surprised when

    m = Matrix.I(10)
    m[0,1] = -1

    threw an error.
     
    M. Edward (Ed) Borasky, Aug 6, 2006
    #1
    1. Advertising

  2. M. Edward (Ed) Borasky

    Dave Burt Guest

    M. Edward (Ed) Borasky wrote:
    > Some time back, RCR 161 was submitted to add a []= method to the Matrix
    > class defined in "matrix.rb". Apparently, this was imported from an
    > older database and needs to be resubmitted. Can "anyone" (for example,
    > me) do that, or does it have to be the original submitter?


    The problem with this RCR, if I recall correctly, is that Matrix objects
    are immutable, and []= is a mutation operation.

    There's room for methods that return a copy of the matrix modified in a
    given way, but you can't change self.

    Cheers,
    Dave
     
    Dave Burt, Aug 6, 2006
    #2
    1. Advertising

  3. Dave Burt wrote:
    > M. Edward (Ed) Borasky wrote:
    >
    >> Some time back, RCR 161 was submitted to add a []= method to the Matrix
    >> class defined in "matrix.rb". Apparently, this was imported from an
    >> older database and needs to be resubmitted. Can "anyone" (for example,
    >> me) do that, or does it have to be the original submitter?
    >>

    >
    > The problem with this RCR, if I recall correctly, is that Matrix objects
    > are immutable, and []= is a mutation operation.
    >
    > There's room for methods that return a copy of the matrix modified in a
    > given way, but you can't change self.
    >
    > Cheers,
    > Dave
    >

    I guess I need to define my own "Matrix" class then. Making a copy of a
    200x200 matrix to change one element, or in my case the whole upper
    triangle, is not going to work. I ended up doing "a = m.to_a", changing
    the upper triangle in "a", and then doing "m = Matrix.rows(a)". Until I
    looked at the code, I thought Matrix was either inheriting from or
    mixing in Array.

    Still, at least one other person -- the person who filed RCR 161 --
    thought that "m[i, j] = -1" was something a "Matrix" object like "m"
    should know how to do. It's such a common operation in matrix
    computations that its non-existence seems more like an oversight than a
    design feature or a bug to me. And it violates the principle of being
    able to write FORTRAN code in any language. :)
     
    M. Edward (Ed) Borasky, Aug 6, 2006
    #3
  4. M. Edward (Ed) Borasky

    Dave Burt Guest

    M. Edward (Ed) Borasky wrote:
    > I guess I need to define my own "Matrix" class then. Making a copy of a
    > 200x200 matrix to change one element, or in my case the whole upper
    > triangle, is not going to work. I ended up doing "a = m.to_a", changing
    > the upper triangle in "a", and then doing "m = Matrix.rows(a)". Until I
    > looked at the code, I thought Matrix was either inheriting from or
    > mixing in Array.


    It's immutable so you can treat it like Numeric objects.

    Check out narray on the RAA, it might be what you're looking for.
    Apparently it's fast, too.

    http://raa.ruby-lang.org/project/narray/

    Cheers,
    Dave
     
    Dave Burt, Aug 7, 2006
    #4
  5. Dave Burt wrote:
    > M. Edward (Ed) Borasky wrote:
    >
    >> I guess I need to define my own "Matrix" class then. Making a copy of a
    >> 200x200 matrix to change one element, or in my case the whole upper
    >> triangle, is not going to work. I ended up doing "a = m.to_a", changing
    >> the upper triangle in "a", and then doing "m = Matrix.rows(a)". Until I
    >> looked at the code, I thought Matrix was either inheriting from or
    >> mixing in Array.
    >>

    >
    > It's immutable so you can treat it like Numeric objects.
    >
    > Check out narray on the RAA, it might be what you're looking for.
    > Apparently it's fast, too.
    >
    > http://raa.ruby-lang.org/project/narray/
    >
    > Cheers,
    > Dave
    >

    I am looking *at* narray, and I am looking *for* code that does matrix
    operations with rational and possibly complex rational matrix elements
    and I am looking *to* find ways to tune the Ruby interpreter to do these
    efficiently. :) I may end up, when all the smoke has cleared, with
    narray, or GSL, or LAPACK or a home-brew interface to a C/C++ symbolic
    math package like Singular or Ginac. But right now, my focus is on
    Matrix and how to make it better in pure Ruby.

    The application I have in mind will use smallish matrices -- the 200x200
    test case I posted is probably both bigger and more ill-conditioned than
    I will need. The application uses lots of matrix algebra to break large
    problems up into block-tridiagonal matrices and other structured forms.
    Before I look at alternatives, I want to see what I can build with pure
    Ruby and the Matrix/Mathn/Rational/Complex libraries.
     
    M. Edward (Ed) Borasky, Aug 7, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski

    Refreshing without resubmitting

    Nathan Sokalski, Jun 30, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    631
    David C. Holley
    Jul 2, 2004
  2. Michael Muller
    Replies:
    2
    Views:
    2,252
    Neomorph
    Sep 18, 2003
  3. mdh

    p 161...File access

    mdh, Sep 29, 2008, in forum: C Programming
    Replies:
    17
    Views:
    587
    Keith Thompson
    Sep 29, 2008
  4. Nathan Sokalski

    Refreshing without resubmitting

    Nathan Sokalski, Jun 30, 2004, in forum: ASP General
    Replies:
    4
    Views:
    132
    David C. Holley
    Jul 2, 2004
  5. Andy
    Replies:
    1
    Views:
    345
    Mike Brind
    Dec 1, 2006
Loading...

Share This Page