Questions: list processing - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Questions: list processing (/thread-6669.html) Questions: list processing - compsystems - 08-08-2016 03:24 AM sorry for my bad English Example #1: list1 := {{1,2},{3,4},{5,6},{7,8}} → {{1,2},{3,4},{5,6},{7,8}} ans1 := list1^2 → {{1,2},{3,4},{5,6},{7,8}}^2 → ans1 := {{1,4},{9,16},{25,36},{49,64}} // list parallel processing type(ans1) → DOM_LIST // ok, Confirms that it is a list TYPE(ans1) → 6 // ok, Confirms that it is a list dim(ans1) → [4,2] // ok, as the object of the list has matrix dimension (rectangular), calculate its size {n, m} DIM(ans1) → {{1,1},{1,1},{1,1},{1,1}} // ok, one element in each element Example #2: Now changing the container {} → [] /!\ If the list with bracket container, has matrix dimension, then it treated as a matrix or vector (linear algebra and not list parallel processing ) list2 := [[1,2],[3,4],[5,6],[7,8]] → [[1,2],[3,4],[5,6],[7,8]] type(list2) → DOM_LIST // ok, Confirms that it is a list TYPE(list2) → 4 // ok, as the object of the list has matrix dimension dim(list2) → [4,2] // ok, [n, m] DIM(list2) → {4,2}// ok, {n, m} ans2 := list2^2 → ans2 := [[1,2],[3,4],[5,6],[7,8]]^2 → ans2 := 204 // Ok, Change context to vector. VALID BECAUSE NOT SQUARE DIMENSION, OK list2^2 → [[1,2],[3,4],[5,6],[7,8]]^2 → [1,2,3,4,5,6,7,8]^2 → [1,2,3,4,5,6,7,8] * [1,2,3,4,5,6,7,8] → DOT( [1,2,3,4,5,6,7,8], [1,2,3,4,5,6,7,8]) → 204 // ok valid can be interpreted here as dot product Example #3: list3 := {{1,2},{3,4}} → {{1,2},{3,4}} ans3 := list3^2 → ans3 := {{1,2},{3,4}}^2 → ans3 := {[1,4],[9,16]} // list parallel processing QUESTION 1: Why combined container {[],[]}? The result should be? ans3 := {{1,4},{9,16}} Example #4: list4 := [[1,2],[3,4]] → [[1,2],[3,4]] ans4 := list4^2 → ans4 := [[1,2],[3,4]]^2 → [[7,10],[15,22]] // ok, Context switch to square matrix type(ans4) → DOM_LIST // ok TYPE(ans4) → 4 // ok dim(ans4) → [2,2] // ok, [n, m] DIM(ans4) → {2,2}// ok, {n, m} Example #5: list5 := [[1,2],[3,4],[5,6],[7,8]] → [[1,2],[3,4],[5,6],[7,8]] ans5 := list5^3 → ans5 := [[1,2],[3,4],[5,6],[7,8]]^3 → ans5 := [[1,8],[27,64],[125,216],[343,512]] // ok, Context as list type(ans5) → DOM_LIST // ok TYPE(ans5) → 4 // ok dim(ans5) → [4,2] // ok, [n, m] DIM(ans5) → {4,2}// ok Example #6: list6 := {{1,2},{3,4},{5,6},{7,8}} → {{1,2},{3,4},{5,6},{7,8}} ans6 := list6^3 → ans6 := [[1,2],[3,4],[5,6],[7,8]]^3 → ans6 := {{1,8},{27,64},{125,216},{343,512}} // ok type(ans6) → DOM_LIST // ok TYPE(ans6) → 6 // ok dim(ans6) → [4,2] // ok, [n, m] DIM(ans6) → {{1,1},{1,1},{1,1},{1,1}} // ok RE: Questions: list processing - cyrille de brébisson - 08-08-2016 05:44 AM Hello, Thanks, we will add this issue to the list. cyrille RE: Questions: list processing - parisse - 08-08-2016 06:35 AM Short answer: you should use .^ instead of ^ (or .* .+ .-) for list processing with CAS objects. Explanation: ^ does call the so-called fast exponentiation algorithm. This algorithm initializes the result to 1 and does multiplications with the power basis to powers of 2, at some point you have therefore a scalar times a DOM_LIST object, and this is interpreted as a multiplication by a dense 1-d polynomial.