CONCAT/APPEND/PREPEND CAS FUNCTION
07-30-2016, 03:08 AM (This post was last modified: 08-08-2016 03:07 AM by compsystems.)
Post: #1
 compsystems Senior Member Posts: 1,382 Joined: Dec 2013
CONCAT/APPEND/PREPEND CAS FUNCTION
CONCAT(ARG1, ARG2) FUNCTION CAS Example

FIRST ARGUMENT A MATRIX OR VECTOR ARRAY or LISTS with matrix dimension (nxm)
mat1 := [[a,b],[c,d]] [Enter] returns [[a,b],[c,d]] Matrix (2rowsx2cols) OK

Case 1:

vec1 := [[1],[2]] [Enter] returns [[1],[2]] Matrix (2rowsx1cols) or Column Vector (2 Elements) OK

concat(mat1,vec1) returns [[a,b,1],[c,d,2]] Matrix (2rowsx3cols) OK Concatenates to the right, because the second argument is a column vector

Case 2:

vec2 := [[3,4]] [Enter] returns [[3,4]] Matrix (1rowsx2cols) or Row Vector (2 Elements) OK

concat(mat1,vec2) returns [[a,b],[c,d],[3,4]] Matrix (3rowsx2cols) OK Concatenates down, because the second argument is a row vector

Case 3:

vec3 := [[3,4,5]] Returns [[3,4,5]] Matrix (1rowsx3cols) or Row Vector (3 Elements) OK

concat(mat1,vec3) returns [[a,b]],[c,d], [3,4,5]] Concatenates down because the second argument is a row vector with more columns than the firts argument

but (to put the answer to the entry line [up] [copy] show empty elements)

[up] [copy] [[a,b, □],[c,d, □],[3,4,5]] Matrix (3rowsx3cols) WITH EMPTY ELEMENTS (□)
07-30-2016, 07:51 AM
Post: #2
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: [Request] fill zeros in vectors and matrices with empty elements
concat([[a,b],[c,d]],[[3,4,5]]) returns a list of 3 lists with different sizes, it's not a matrix anymore. Your matrix arguments must have the same number of lines for matrix concatenation.
07-30-2016, 12:33 PM (This post was last modified: 07-30-2016 04:23 PM by compsystems.)
Post: #3
 compsystems Senior Member Posts: 1,382 Joined: Dec 2013
RE:
Another Example with CONCAT CAS FUNCTION

FIRST ARGUMENT A LIST without matrix dimension, only elements

Case 4:

list1 := {abc, {d,e} , f} [ENTER] returns {abc, {d,e}, f} // a List with 3 Elements OK
list2 := {{g,h}} [ENTER] returns {{g,h}} // a List with 1 Elements, in this case it is also a row matrix (1x2). OK

concat(list1,list2) [ENTER] returns {abc,{d,e},f, {g,h} }// a List with 4 Elements OK

Case 5:

list3 := [abc, [d,e] , f] [ENTER] returns [abc, [d,e] , f] // a List with 3 Elements OK
list4 := [[g,h]] [ENTER] returns [[g,h]] // a List with 1 Elements, in this case it is also a row matrix (1x2). OK

concat(list3,list4) [ENTER] returns [abc,[d,e],f,[g,h]] // a List with 4 Elements OK

Case 6:

list3 := [abc, [d,e] , f] [ENTER] returns [abc, [d,e] , f] // a List with 3 Elements OK
list2 := {{g,h}} [ENTER] returns {{g,h}} // ok

concat(list3,list2) [ENTER] returns [abc, [d,e], f, {g,h}] // a List with 4 Elements OK

Case 7:

list1 := {abc, {d,e} , f} [ENTER] returns {abc, {d,e}, f} // ok
list4 := [[g,h]] [ENTER] returns [[g,h]] // ok

concat(list1,list4) [ENTER] returns{abc, {d,e} , f, [g,h]} // a List with 4 Elements OK
07-30-2016, 12:37 PM (This post was last modified: 07-30-2016 02:40 PM by compsystems.)
Post: #4
 compsystems Senior Member Posts: 1,382 Joined: Dec 2013
RE:
(07-30-2016 07:51 AM)parisse Wrote:  concat([[a,b],[c,d]],[[3,4,5]]) returns a list of 3 lists with different sizes, it's not a matrix anymore. Your matrix arguments must have the same number of lines for matrix concatenation.

Here there is an error, if not is a matrix, the output should not add empty fields to copy to the entry line

concat(mat1,vec3) returns [[a,b,[c,d],[3,4,5]]

In the history is not displayed, but to copy to the entry line following the key sequence ([up] [copy]) if displayed the empty fields

[[a,b, □],[c,d, □],[3,4,5]]

Attached File(s) Thumbnail(s)

07-30-2016, 01:33 PM
Post: #5
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: [Request] fill zeros in vectors and matrices with empty elements
It's not output, it's input, in textbook mode, it's not related to the CAS therefore I won't comment.
07-30-2016, 02:12 PM (This post was last modified: 07-30-2016 03:04 PM by compsystems.)
Post: #6
 compsystems Senior Member Posts: 1,382 Joined: Dec 2013
RE:
yes , now I realize. it really is another problem of COPY system function and not CONCAT CAS,
copy function should check first if the output a true matrix array and then convert to template
the output to the entry line should be shown as follows image

Attached File(s) Thumbnail(s)

07-30-2016, 02:47 PM (This post was last modified: 07-30-2016 05:01 PM by compsystems.)
Post: #7
 compsystems Senior Member Posts: 1,382 Joined: Dec 2013
RE:
Now I am using the APPEND/PREPEND CAS FUNCTION,

Case 1:
mat1 := [[a,b],[c,d]] [Enter] returns [[a,b],[c,d]] Matrix (2rowsx2cols) OK
vec0 := [[1,2]] returns [[1,2]] Matrix (1rowx2cols) or AKA Row Vector (2 Elements) OK
append(mat1,vec0) returns [ [a,b], [c,d], [[1,2]] ] ok
prepend(mat1,vec0) returns [ [[1,2]], [a,b], [c,d]] ok

Case 2:
mat1 := [[a,b],[c,d]] [Enter] returns [[a,b],[c,d]] Matrix (2rowsx2cols) OK
vec1 := [[1],[2]] [Enter] returns [[1],[2]] Matrix (2rowsx1col) or AKA Column Vector (2 Elements) OK

APPEND

append(mat1,vec1) [Enter] returns [ [a,b], [c,d], [[1],[2]] ] OK a list of 3 elements
string(append(mat1,vec1) ) [Enter] returns ""[ [a,b], [c,d], [[1],[2]]]"" OK
dim(append(mat1,vec1)) [Enter] returns 3 elements OK

PREPEND

prepend(mat1,vec1) [Enter] returns [ [[1],[2]], [a,b], [c,d] ] ok a list of 3 elements
string(prepend(mat1,vec1)) returns "[ [[1],[2]], [a,b], [c,d] ]"
dim(prepend(mat1,vec1)) [Enter] returns [3,2] ???

Case 3:
mat1 := [[a,b],[c,d]] [Enter] returns [[a,b],[c,d]] Matrix (2rowsx2cols) OK
list5 := [1,2] [Enter] returns [1,2] List (2 Elements) OK

append(mat1,list5) [Enter] returns [[a,b],[c,d],[1,2]] OK
dim(append(mat1,list5)) [Enter] returns [3,2] ok

prepend(mat1,list5) [Enter] returns [[1,2],[a,b],[c,d]] OK
dim(prepend(mat1,list5)) [Enter] returns [3,2] ok
07-30-2016, 04:50 PM
Post: #8
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: CONCAT/APPEND/PREPEND CAS FUNCTION
append/prepend adds an element to a list, it does not glue matrices together.
08-01-2016, 08:46 PM
Post: #9
 Tim Wessman Senior Member Posts: 2,293 Joined: Dec 2013
RE: CONCAT/APPEND/PREPEND CAS FUNCTION
I don't believe there is any error here with the editor or COPY. The 2D editor doesn't allow you to skip entry of required items. The CAS might allow you to create a vector of vectors containing differing lengths, but as pointed out that is no longer a matrix. Thus when you copy it in, it correctly identifies two places with missing items.

TW

Although I work for HP, the views and opinions I post here are my own.
08-01-2016, 11:40 PM (This post was last modified: 08-01-2016 11:56 PM by compsystems.)
Post: #10
 compsystems Senior Member Posts: 1,382 Joined: Dec 2013
RE: CONCAT/APPEND/PREPEND CAS FUNCTION
Example

mat1 := [[a,b],[c,d]] [Enter] returns [[a,b],[c,d]] Matrix (2rowsx2cols) OK
vec1 := [[1],[2]] returns [[1],[2]] Matrix (2rowsx1col) or AKA Column Vector (2 Elements) OK

append(mat1,vec1) [Enter] returns [ [a,b], [c,d], [[1],[2]] ] OK a LIST of 3 elements but not a matrix array
dim(append(mat1,vec1)) [Enter] returns 3 elements OK, Confirms that it is a list

firts element: [a,b]
Second: [c,d]
Third: [[1],[2]]

This would be the true fit to an array
[
[a,b],
[c,d],
[1,0],
[2,0]
]

but not

[
[a,b],
[c,d],
[1],[2]
]

there is a problem

rref(append(mat1,vec1)) [enter] "Error: Bad Argument Value"
true. the NEXT matrix is a matrix wrong

[
[a,b],
[c,d],
[1],[2]
] this is a matrix? not

Simply, if the list has no matrix dimension, should not be set to a matrix, because in most cases is not feasible
08-02-2016, 04:04 PM (This post was last modified: 08-02-2016 04:05 PM by Tim Wessman.)
Post: #11
 Tim Wessman Senior Member Posts: 2,293 Joined: Dec 2013
RE: CONCAT/APPEND/PREPEND CAS FUNCTION
(08-01-2016 11:40 PM)compsystems Wrote:  [
[a,b],
[c,d],
[1],[2]
] this is a matrix? not

No, it is not. That is a vector of 2, two length vectors, and a two one item vectors.

Quote:dim(prepend(mat1,vec1)) [Enter] returns [3,2] ??? Contradiction

No, it isn't. You have 3 items, with a maximum size of 2 in the other direction. That does not mean you can't have fewer then 2 in a specific position. The CAS does not have a "matrix" object. It only has vectors that can contain other objects. A "matrix" is a vector of equal length vectors. Anything else is simply a vector of assorted objects.

You are correct that the 2D editor does not support this type of entry. This is by design due the two simple facts that a) there are not really any direct uses for this type of object in the various math commands - it is only really useful during programming and b) to support it would mean making the 2D editor allow this type of input which is detrimental to nearly every single user.

TW

Although I work for HP, the views and opinions I post here are my own.
 « Next Oldest | Next Newest »

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