Vector Shape

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Vector Shape

Paul Keir

Hi,

 

I’m just curious, why is the length of the dimension vector of a one dimensional array (Array.h) two, instead of one?

 

e.g.

 

Array<int> foo(7);

std::cout << foo.dims().str() << std::endl;

std::cout << foo.is_vector() << std::endl;

 

displays:

 

7x1

1

 

I would have thought I’d get:

 

7

1

 

Thanks in advance,

Paul

 



The University of Glasgow, charity number SC004401

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Vector Shape

John W. Eaton
Administrator
On 30-Apr-2010, Paul Keir wrote:

| Hi,
|
| I'm just curious, why is the length of the dimension vector of a one dimensional array (Array.h) two, instead of one?
|
| e.g.
|
| Array<int> foo(7);
| std::cout << foo.dims().str() << std::endl;
| std::cout << foo.is_vector() << std::endl;
|
| displays:
|
| 7x1
| 1
|
| I would have thought I'd get:
|
| 7
| 1

Because the Array class in liboctave was designed specifically for
implementing the Octave language, which, like Matlab does not have
arrays with only one dimension.  Every array object has at least two
dimensions.

jwe
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Vector Shape

David Bateman
In reply to this post by Paul Keir
For two reasons

- Its compatible with matlab
- It allows a distinction between row and column vectors using the same C++ class as a matrix.

D.