If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Matrix data type+

I am doing the same thing!!! I am debating whether to use arrays like you
say, but I am also thinking about a vector of vectors... just because I think
memory issues will be easier to handle. I have built two Vector classes,
1 using arrays and the other with vectors... They both work perfectly, but
I found the one implemented with vectors easier to program (although I did
it after I finished one using arrays).

Sorry that doesn't answer your question... it's just neat to see people with
similar projects :)

Re: Matrix data type+

Single is easier for some operations, 2d is easier for access /human thought.
I posted a full set with single a couple of days back, for something to
compare it to. The internal speed is not different either way. At the time,
single seemed easier for dynamic allocation, and for the operations I was
doing.

Re: Matrix data type+

This is true, but 2*number of cols + 3 is the same thing, and the math is
the same internally. And use [0][0] for first one? (changes the indices
above, but same again), again, see the code I sent last week.

Sheshadri Iyengar <sheshadri.i@kshema.com> wrote:
>
>I feel usage of two-dimensional array is better.
>
>>> I'm wondering how I should store the data internally.
>For ex: int mat[2][3];
>
>where number 2 refers to number of rows count and 3 refers to the number
of
>columns and
>you can access the first matrix element by mat[1][1] and the rest like that.
>
>with regards
> shesh
>
>
>Mike wrote:
>
>> Hi,
>>
>> I'm creating a matrix data type. A matrix is a structure that stores
elements
>> in rows and columns.
>>
>> For Example: | 1 2 3 |
>> | 5 4 3 |
>> | 3 0 8 |
>>
>> I'm wondering how I should store the data internally. Should I use a
single
>> dimentional or 2-dimensional array.
>> Which one do you think is faster or better?
>>
>> Thanks
>>
>> Mike
>

Re: Matrix data type+

I think it's worthwile remembering you all that you're programmin in C++,
that is not C!
The most efficient and elegant way to do tour task is using STL valarray
(an improved vector to perform efficient mathematical computations) and STL
slices (that is, setting dimensions in your array to have matrices).
Bye,
-Andrea

"Scott" <particleman@chalktv.com> wrote:
>
>I am doing the same thing!!! I am debating whether to use arrays like you
>say, but I am also thinking about a vector of vectors... just because I
think
>memory issues will be easier to handle. I have built two Vector classes,
>1 using arrays and the other with vectors... They both work perfectly, but
>I found the one implemented with vectors easier to program (although I did
>it after I finished one using arrays).
>
>Sorry that doesn't answer your question... it's just neat to see people
with
>similar projects :)
>
>Scott
>
>
>"Mike" <Mjg_01@yahoo.com> wrote:
>>
>>Hi,
>>
>>I'm creating a matrix data type. A matrix is a structure that stores elements
>>in rows and columns.
>>
>>For Example: | 1 2 3 |
>> | 5 4 3 |
>> | 3 0 8 |
>>
>>I'm wondering how I should store the data internally. Should I use a single
>>dimentional or 2-dimensional array.
>>Which one do you think is faster or better?
>>
>>Thanks
>>
>>Mike
>