implemeting sparse and non-sparse matrixes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ishakteyran
    New Member
    • Jul 2007
    • 8

    implemeting sparse and non-sparse matrixes

    hello to all.. i have a realy tough assignment which requires me to add, substract, multiply, and get inverse of non-sparse and sparse matrixes..

    in a more clear way it wants me to to the operations listed above between two sparse, or non-sparse or a sparse and a non-sparse matrix..

    for the operations an the matrixes of same kind, say sparse matrix, it seems rather easy .. but what makes me cobfuse is how to operate a sparse with a non-sparse..

    and of course for both which data structure is the best? list, vector, array,.... ?

    i will be very appreciated with any kind of help..

    thanks..
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Originally posted by ishakteyran
    but what makes me cobfuse is how to operate a sparse with a non-sparse..

    and of course for both which data structure is the best? list, vector, array,.... ?
    For your first point, does this give you any ideas?
    [CODE=Java]interface Maxtrix {...}

    class SparseMatrix implements Matrix {...}

    class NonSparseMatrix implements Matrix{...}[/CODE]

    As for implementing a SparseMatrix, was there no discussion in your class? May I suggest something that rhymes with bugle?

    Comment

    • Laharl
      Recognized Expert Contributor
      • Sep 2007
      • 849

      #3
      The standard data structure for matrices is a 2D array. You could probably use Vectors or ArrayLists without much trouble, but LinkedLists are not recommended because having to linearly access every element is going to kill your code's efficiency.

      Do you understand how these operations are performed outside of a computer and can you write the algorithms to do so in psuedocode? If so, you can translate them into code from there.

      EDIT: Ninja'd. Those would probably work too...
      Last edited by Laharl; Dec 7 '07, 04:39 AM. Reason: Ninja'd

      Comment

      • ishakteyran
        New Member
        • Jul 2007
        • 8

        #4
        Originally posted by BigDaddyLH

        As for implementing a SparseMatrix, was there no discussion in your class? May I suggest something that rhymes with bugle?
        what dou you mean with the sentences i quoted.. ? at school it is never given a discussion how to solve assignments and in class we only focus on the strucuture or data structures rather than for implementation of what they are best suitable..

        and what means "something taht rhymes with bugle"?

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by ishakteyran
          and what means "something taht rhymes with bugle"?
          Anglo Saxons can't rhyme but my guess is 'google' ;-)

          kind regards,

          Jos

          Comment

          Working...