
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center

×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
 HP Community
 >
 Other Products
 >
 Calculators
 >
 How to write a square root elements in diagonal of square ma...
 Mark Topic as New
 Mark Topic as Read
 Float this Topic for Current User
 Bookmark
 Subscribe
 Mute
 Printer Friendly Page
Create an account on the HP Community to personalize your profile and ask a question
Solved!
How to write a square root elements in diagonal of square matrix
10062017 03:53 PM
Hello HP community ,
I have one question , I' m going little bit programming in User RPL and i have one problem that I didn't solve jet.
Here is example of my task.
I have square matrix of any dimension (nxn) and I want to write a vector ( n x 1 ) which have elements equal to a square root of individually elements in square matrix at its main diagonal , and of course i want to store the vector (nx1) into global variable .
How to write this type of program , please help me
Can anyone write me an answer , i have code for this program but is not good because my program prints a numbers without a sign of vector when i store these number to array .
I have also a simbollicaly a picture , what I supposed to do with this program .
there is my source code ...
<< 3 SF Qxx SIZE 1 GET 'DIM' STO 1 DIM
FOR i 1 DIM
FOR j
IF i j ==
THEN Qxx { i j }
GET square root sign
END
NEXT
NEXT
>>
Please Help me HP community i don't know what to do .
Solved! Go to Solution.
10072017 01:01 AM
Not sure I understand what you're seeking, but if you want to extract the diagonal of a square matrix into a vector, and square root its elements individually, here's one way to do that (replace "sqrt" with the square root symbol):
→DIAG AXL sqrt AXL
Here's another way:
→DIAG « sqrt » MAP
Disclaimer: I don't work for HP. I'm just another happy HP calculator user.
10072017 03:14 AM
f yes thanks , but i have one task for these vector , i want also transponse that vector and multiplied them with the real number or one another vector , maybe better said matrix dim. n x 1 , when I going to do that it shows me something like that ( in the picture below )
And do you know easiest way to get a squareroots of elements in main diagonal in form of square matrix but i want that does works on any dimensions of matrix , of course i have picture for that also , i would be very very gretefull if you give me the answer on that question ,
But for now you've helped me a lot , thank you colleage 😃
10072017 11:09 AM  edited 10072017 11:22 AM
When I understand you well you have a vector of the form [2,4,7,2] and you want to transform it into a column matrix of the form [[2],[4],[7],[2]].
I would do this: first transform your vector into a list with AXL (with thanks to Joe)
Then evaluate your list, so this puts the elements on the stack.
Then enter the list: {n,1}.
n is the number of rows and 1 is the number of columns
Then use →ARRY.
This transforms the elements on the stack to a matrix of size n*1, which is what you want.
EDIT
I understand that you already have the elements of the vector on the stack.
So the only thing left to do is entering {n,1} followed by →ARRY
10072017 01:00 PM
The fastest way to turn a vector into a matrix is with the RDM (ReDiMension) command:
[7, 8, 9] {3 1} RDM > [[7], [8], [9]] (a column matrix)
[7, 8, 9] {1 3} RDM > [[7, 8, 9]] (a row matrix)
A way to programmatically turn any vector into a column matrix is DUP SIZE 1 + RDM.
Joe
10082017 07:21 AM  edited 10082017 07:39 AM
I now realize that the method I suggested in message 4 was not very good. Beginner's work!
Of course Joe's method is much better.
Still another way to transform [2,4,7,2] into [[2],[4],[7],[2]] would be:
Use OBJ → to put the elements of the vector on the stack.
Level 1 will now contain {n} (n is the length of the vector)
Add 1, level 1 will now contain {n,1}
Use →ARRY to transform the elements on the stack into a n*1 matrix.
Also, apart from the command GET, the command PUT is very important.
Because your aim was to construct a n*1 matrix you could have created such a matrix with
CON ({n,1},0)
This command creates a matrix with dimensions n*1, where all elements are constants, in this case equal to 0.
Next store this matrix in variabel M1.
Next, when you would like element (3,1) of this matrix to be 7, just use:
PUT (M1,{3,1},7)
10112017 11:02 AM
You also wanted to know how to construct a matrix with same dimension as original matrix, with all elements equal to 0, except the diagonal elements, which are equal to the square root of the diagonal elements of the original matrix.
You know already how to obtain a vector with these elements.
You are a lucky guy because there is a command for this.
When the vector is on the stack you just have to write:
DIM DIAG→
The command is described in both the ordinary User's Guide and the Advanced one:
http://h10032.www1.hp.com/ctg/Manual/c00748644
http://h10032.www1.hp.com/ctg/Manual/c02836298
Both manuals are very useful, the second one mainly (at least for me) because it describes all commands.
You could also write a program which creates such a matrix by using a loop, and the commands CON, GET and PUT.
Such a program could be:
{DIM DIM} 0 CON
'M1' STO
1 DIM FOR i
'M1' {i i}
Qxx {i i} GET sqrt
PUT
NEXT
M1
Here Qxx is the name of your original matrix, with dimension DIM*DIM
Explanation:
{DIM DIM} 0 CON:
creates a square matrix with all elements equal to 0 and dimension DIM*DIM. (CON=constant)
'M1' STO: stores this matrix in variable M1.
1 DIM FOR i : starts the loop.
Qxx {i i} GET sqrt : takes the roots of the diagonal elements of Qxx.
'M1' {i i} ....PUT: puts them into M1
10192017 09:06 AM
Didn't find what you were looking for? Ask the community