Jump to content



Photo
- - - - -

Square root for each matrix/vector cell?


  • Please log in to reply
2 replies to this topic

#1 MarioR

MarioR

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    Classpad II

Posted 21 November 2016 - 09:46 PM

Hallo,

 

the next problem.

I have an vector or a matrix in which each cell is a square of a number. Now i need a matrix in which each cell is the square root of the source matrix cell.

 

Example:

 

  4   9  16         2  3  4

25 36    9   =>  5  6  3

36 49  64         6  7  8

 

The equal problem is "example" backwards (sqare of each cell).

 

 

regards Mario



#2 MarioR

MarioR

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    Classpad II

Posted 21 November 2016 - 11:36 PM

Hello,

 

i have make a litle progam for this, but it is litle bit slowly:

local matCoMax,matRoMax
local matCo,matRo
colDim(mat)⇒matCoMax
rowDim(mat)⇒matRoMax
If matCoMax>0 
Then
 If matRoMax>0
 Then
  For 1⇒matCo To matCoMax
   For 1⇒matRo To matRoMax
    srt(mat[matRo,matCo])⇒mat[matRo,matCo]
   Next
  Next
  Return mat
 IfEnd
IfEnd

Is there no faster solution?

regards Mario


Edited by MarioR, 22 November 2016 - 12:09 AM.


#3 pan.gejt

pan.gejt

    Casio Freak

  • Members
  • PipPipPipPip
  • 137 posts
  • Gender:Male
  • Location:CZ

  • Calculators:
    fx-880, fx-6300G, fx-9700GE, fx-9860G Slim, Classpad 330-A, TI-Nspire + keypad, TI-Nspire CAS, TI-Nspire CX CAS,TI-89 Titanium, HP-50g, SEC-101, fx-991ES PLUS, fx-991DE PLUS, fx-CP400, Canon X MARK I PRO, Citizen SRP-75,

Posted 22 November 2016 - 07:20 AM

Another 2 solutions

 

the 1st solutions- input all elements in program, dimension 3×3

 

ClrText

Input A
Input B
Input C
Input D
Input E
Input F
Input G
Input H
Input I
sqrt({A,B,C})->list1
sqrt({D,E,F})->list2
sqrt({G,H,I})->list3
listToMat(list1,list2,list3)->A
Print "SQRT OF ELEMENTS IS"
Print trn(A)

 

notice: sqrt is calculated for positive roots only 

           trn means transposition of matrix A

           the templates are not working in program, so the matrix is displayed in 1 row - [[A,B,C],[D,E,F],[G,H,I] ]

           if you want TO display the matrix as the template you need to switch from program to main application

 

 

or you can use parameter variable box and in this case you don't need the Input commands. Just enter into box all variables A,B,C,D,E,F,G,H,I and before running the program fill numbers 4,9,16,25,36,9,36,49,64 into the box parameter 

 

ClrText

sqrt({A,B,C})->list1
sqrt({D,E,F})->list2
sqrt({G,H,I})->list3
listToMat(list1,list2,list3)->A
Print "SQRT OF ELEMENTS IS"
Print trn(A)

           

----------------------------------------------

the 2nd solution - all elements are entered into matrix A in main application

 

 

ClrText
colDim(A)->n
n-2->o
n-1->p
trn(A)->A
matToList(A,o)->listo
matToList(A,p)->listp
matToList(A,n)->listn
listToMat(sqrt(listo),sqrt(listp),sqrt(listn))->B
Print "SQRT OF ELEMENTS IS"
Print B


Edited by pan.gejt, 22 November 2016 - 07:32 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users