Post Reply 
SIZE()
06-23-2015, 10:39 AM (This post was last modified: 06-23-2015 11:16 AM by Angus.)
Post: #1
SIZE()
SIZE(M) returns a list which contains the dimension of Matrix M.
When M is a vector SIZE() returns a list with one value? Is that a bug? I mean if M:=[1,2,3,4,5] SIZE(M) should be {1,5} and not {5}. How would I distinguish a vector from a matrix I think that is inconsistant. Or am I missing something?

Thank you!


edit: the promblem came up in a small program where I want to use SIZE(M1) as an integer value. No success. I then played with size in the homescreen like in the attachement.




update: using length() works, but as i understood length writen in small letters is cas command. And SIZE is home command and should be priorized.
And in home the question remains.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
06-23-2015, 02:41 PM
Post: #2
RE: SIZE()
Hello,

A vector has no dimensional input other then length. Don't forget that you can have a matrix with a single row.

SIZE([[1,2,3,4,5]]) -> {1,5}
SIZE([1,2,3,4,5]) -> {5}

Basically, if you have two items in your list, it is a matrix. If there is only one, it returns a single number as length. We return a list to make it consistent to access the items within.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
06-24-2015, 08:17 AM (This post was last modified: 06-24-2015 08:20 AM by Angus.)
Post: #3
RE: SIZE()
There is MAKELIST and MAKEMAT. Is there a MAKEVEC? I cannot find anything like it.

I have difficulties with vectors and 1 dimensional matrices being different types. My Problem is atm. I have a Vector. i define it as M1:=[0,1,2,3,4,5,6,7]; Fine. It can be stored in M1 which is a Matrix! First surprise for me that it is not a Matrix but a Vector. i.e. a Matrix of one column is something different... :-(

My initial problem was that I tried a piecewise DOT() over the above vector to achieve an FIR filtering with a core.
I can generate core:=MAKELIST(....) But DOT() gives bad argument type. When I try something like: DOT(SUB(data,first,length(core)+first-1),core);

How can I convert a List into a compatible vector or even better: is there a functino like MAKELIST or MAKEMAT for vectors.

I really was under the impression that a vector is always a 1-dimensional Matrix. Now there is kind of confusion on the types. And why they are compatible enough to store a vector in M1.

Is enlightening doable? :-))
Find all posts by this user
Quote this message in a reply
06-24-2015, 08:37 AM
Post: #4
RE: SIZE()
(06-24-2015 08:17 AM)Angus Wrote:  There is MAKELIST and MAKEMAT. Is there a MAKEVEC? I cannot find anything like it.
[...]
How can I convert a List into a compatible vector or even better: is there a function like MAKELIST or MAKEMAT for vectors.

Yes: MAKEMAT(expression, elements), where you define the number of elements for a vector instead of the number of rows and columns for a matrix.

(see manual p474 "Matrices > Matrix functions > Create")
Find all posts by this user
Quote this message in a reply
06-24-2015, 08:43 AM
Post: #5
RE: SIZE()
Ecce enlightenment!

A point is not a line, a line is not a surface, a surface is not a volume.......

A number is not a vector, a vector is not a matrix, a matrix is not a hyper matrix....
Find all posts by this user
Quote this message in a reply
06-24-2015, 09:23 AM
Post: #6
RE: SIZE()
Thanks! MAKEMAT variant solves the problem.

Well, a Vector is a Matrix if I can store it in M1, isn't it? ;-))
Find all posts by this user
Quote this message in a reply
06-24-2015, 10:35 AM
Post: #7
RE: SIZE()
Well...I just stored the number 6 to M1...so I guess you say 6 is a vector?
Find all posts by this user
Quote this message in a reply
06-24-2015, 10:36 AM
Post: #8
RE: SIZE()
Sorry, my error...I guess you say 6 is a matrix?
Find all posts by this user
Quote this message in a reply
06-24-2015, 10:55 AM (This post was last modified: 06-24-2015 10:59 AM by Angus.)
Post: #9
RE: SIZE()
Sorry. It is that I still have my problems with the variable system. Mostly my fault, partly because I still don't see the benefits for students. Plus my related sarcasm seems to got lost.

But (!), yes if I store M1:=6 6 IS converted to a matrix. Try it. You get [[6]] in the history.
Find all posts by this user
Quote this message in a reply
06-24-2015, 11:17 AM
Post: #10
RE: SIZE()
(06-24-2015 10:55 AM)Angus Wrote:  Sorry. It is that I still have my problems with the variable system. Mostly my fault, partly because I still don't see the benefits for students. Plus my related sarcasm seems to got lost.

But (!), yes if I store M1:=6 6 IS converted to a matrix. Try it. You get [[6]] in the history.

Your "converted" betrays an inconsistency in considering 6 already a matrix.

Enlightenment leaves the thread with one last long lingering look behind bewildered.
Find all posts by this user
Quote this message in a reply
06-24-2015, 11:45 AM
Post: #11
RE: SIZE()
(06-24-2015 08:43 AM)Gerald H Wrote:  Ecce enlightenment!

A number is not a vector, a vector is not a matrix, a matrix is not a hyper matrix....

I think a number could be most anything, subject to constraint by context.

The way the number is represented, as an element of an array such as a list, vector, matrix, tensor, etc., helps clarify the constraints. Just because there is only one element in the array, doesn't change the fact that other elements may enter into the basis, or perhaps other elements ARE/WERE there, just that they are zero, and subsequently omitted, for example:

M1:=[[6]]; // Hyper matrix, a matrix of matrices, containing a single matrix vector
M1(1) == [6]; // Matrix containing a single vector
M1(1,1) == 6; // a number, an element of the matrix vector, and of the Hyper matrix

Generally, matrices are a collection of vectors, which are a collection of numbers, or perhaps other things, forming some sort of array.

So, I think a number can be described as a 1xn or nx1 vector, or matrix, unless defined otherwise in some context.
Find all posts by this user
Quote this message in a reply
06-24-2015, 12:13 PM
Post: #12
RE: SIZE()
You folks heard of this one

https://en.wikipedia.org/wiki/Fallacy_of_composition

or of this one

https://en.wikipedia.org/wiki/Fallacy_of_division

???
Find all posts by this user
Quote this message in a reply
06-24-2015, 12:17 PM
Post: #13
RE: SIZE()
Do you agree that it is funny that

M1:=4 ---> [[4]] whereas
M1:=[1 2 3] ---> [1 2 3] instead of something like [[1 2 3]]

I would not like the second version / where should I store vectors.... But it is somehow inconsistant and confusing.

And is there a reason that DOT does not work with vector and matrix even if the matrix dimension is right other than type-mismatch?
Find all posts by this user
Quote this message in a reply
06-24-2015, 12:23 PM
Post: #14
RE: SIZE()
'Tis all a bewilderment, for 5 truly represents 5 bananas, & if we add 5 bananas we get 10 bananas (surely y'all recognise that was matrix addition), but should we multiply them we get 25 square bananas, so they must be a matrix?
Find all posts by this user
Quote this message in a reply
06-24-2015, 12:41 PM
Post: #15
RE: SIZE()
You don't see that it can surely be a problem if it matters at some point if the prime deals with a vector or a matrix and throws errors. It is NOT a thread about formal math...
So I'd say thread finished. No time for postings like yours.
Find all posts by this user
Quote this message in a reply
06-24-2015, 02:51 PM (This post was last modified: 06-24-2015 02:52 PM by DrD.)
Post: #16
RE: SIZE()
Going banana's:

M1:=5; // ==> [[5]] 'nana's
M1+M1; // ==> [25], a lovely bunch in this matrix vector.
DOT(M1,M1); // ==> 25 the number of organic banana's squared, not GMO (the square kind) banana's.

Another bunch:

M1 .* M1; // ==> [25] a vector squarely in this matrix

Which grew from this little start:

M1(1,1); // ==> 5

(Just monkeying around, don't pick on me!)

-Dale-
Find all posts by this user
Quote this message in a reply
06-25-2015, 05:20 AM (This post was last modified: 06-25-2015 05:24 AM by Angus.)
Post: #17
RE: SIZE()
M1:=5; //-->[[5]] *****
M1+M1; //-->[[10]] not [25] (or [10] )
DOT(M1,M1); //--> Error: Invalid dimension

M1:=[5]; //-->[5] *****
M1+M1; //-->[10];
DOT(M1,M1); //25


and finally:

M1:=[1 2];
M2:=[[1 2]];
M3:=TRN(M2); //!!!!
M1+M2; //Error: Invalid dimension
M1+M3; //Error: Invalid dimension



M1:=[1 2 3];
TRN(M1); //-->> [[1
2
3]] //transose of vector.....now matrix.

I have heard of line or column vectors in former days.
you see?

What makes a vector different from a one dimensional matrix?

For the prime it is. Just because of internal types? They are even created by the same Matrix-Tool.
I tried it a last time. I think you won't see my point again (or at least it was not referred), but I wanted to try it.
Find all posts by this user
Quote this message in a reply
06-25-2015, 06:35 AM
Post: #18
RE: SIZE()
What makes a vector different from a matrix?

Is 5 different from the list or set {5}?

Is the set or list {5} different from {{5}}?

I admire my patience - Mencius would have stopped at posting #5.
Find all posts by this user
Quote this message in a reply
06-25-2015, 07:57 AM (This post was last modified: 06-25-2015 08:08 AM by Angus.)
Post: #19
RE: SIZE()
Quote:What makes a vector different from a matrix?

NOTHING except a vector is 1-dimensional. What would you say?


My question to you is? What is the result of a transposed vector? Vector or matrix.

I'd like to cite from https://en.wikipedia.org/wiki/Matrix_%28mathematics%29:
"Matrices which have a single row are called row vectors, and those which have a single column are called column vectors."
Find all posts by this user
Quote this message in a reply
06-25-2015, 10:02 AM
Post: #20
RE: SIZE()
Once more:

The elements constituting a matrix are vectors, the elements constituting a vector are numbers.

Is my argumentation so opaque?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)