Jump to content



Photo

Matrix On Lua


  • Please log in to reply
15 replies to this topic

#1 Colombia

Colombia

    Casio Addict

  • Members
  • PipPipPip
  • 94 posts
  • Gender:Male
  • Location:Venezuela

  • Calculators:
    algebra FX 2.0 plus
    Classpad 300

Posted 13 April 2007 - 05:14 AM

how can i write this on Lua :banghead: :

On basic:

[[1,2][3,4]] => Mat_A
6 => Mat_A[1,1]
PrintNatural Mat_A



:roflol: Thanks!!!!!!!!!!!!!!!

#2 girdeux

girdeux

    Casio Addict

  • Members
  • PipPipPip
  • 88 posts
  • Location:Spain / Castell?n

  • Calculators:
    casio fx-115ms;
    casio classpad 300

Posted 13 April 2007 - 02:29 PM

how can i write this on Lua :banghead: :

On basic:

[[1,2][3,4]] => Mat_A
6 => Mat_A[1,1]
PrintNatural Mat_A
:roflol: Thanks!!!!!!!!!!!!!!!


A={{1,2},{3,4}}
A[1][1]=6

for i=1,#A do
print(unpack(A[i]))
end

That's all.. :roflol:

#3 The_AFX_Master

The_AFX_Master

    Casio Overlord

  • Admin
  • PipPipPipPipPipPipPip
  • 519 posts
  • Gender:Male
  • Location:Black Mesa Research Facility (sector C)
  • Interests:BASIC +FORTRAN 90+ C++.....and HALF LIFE

  • Calculators:
    Casio Algebra FX 2.0 Plus, Casio fx 570 ms, Classpad 300, And a crowbar

Posted 13 April 2007 - 07:40 PM

Colombia... i have a library that makes easy the matrix/list manipulation.. even easier than Basic.. I'm so busy at now because the Formula SAE tune up.. ( Competition is in 34 days!).. so, i'll upload it soon.. at least less than a week

#4 Colombia

Colombia

    Casio Addict

  • Members
  • PipPipPip
  • 94 posts
  • Gender:Male
  • Location:Venezuela

  • Calculators:
    algebra FX 2.0 plus
    Classpad 300

Posted 23 April 2007 - 10:27 PM

why this doesn`t work :banghead:


require("cas")
Mat_A={}
d=input("Dimension of the Matrix:")

for i=1,d do
for j=1,d do
n=input("element "..i..","..j..":")
Mat_A[i][j]=n
end
end

#5 The_AFX_Master

The_AFX_Master

    Casio Overlord

  • Admin
  • PipPipPipPipPipPipPip
  • 519 posts
  • Gender:Male
  • Location:Black Mesa Research Facility (sector C)
  • Interests:BASIC +FORTRAN 90+ C++.....and HALF LIFE

  • Calculators:
    Casio Algebra FX 2.0 Plus, Casio fx 570 ms, Classpad 300, And a crowbar

Posted 23 April 2007 - 11:16 PM

Colombia, don't use the CAS package with LUA to manipulate matrices. ,is weird. Lua tables are powerful enough to handle matrices. see your email today. i'll send you a package for matrix manipulation that make these tasks far easy.

#6 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 24 April 2007 - 09:41 AM

Anyway, this will actually work: ;)

require("cas")
Mat_A={}
d=input("Dimension of the Matrix:")

for i=1,d do
Mat_A[i] = {} -- initialise each row as a table before inserting new elements!
for j=1,d do
n=input("element "..i..","..j..":")
Mat_A[i][j]=n
end
end

#7 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 24 April 2007 - 11:40 AM

*Sigh* Matrix manipulation in CPLua is primitive, just as in C/C++; we had a looong discussion about that in the past, and the conclusion was that matrix manipulation will remain primitive, because the short-lived "mat" package was unavoidably slow.

Anyway, don't use the CAS within CPLua, unless you need it disparately. In this case, you don't have any reason to do so: using the CAS will only make your program slower. Use CPLua's "tables" instead; they are weird, but at least the job can be done.

#8 Colombia

Colombia

    Casio Addict

  • Members
  • PipPipPip
  • 94 posts
  • Gender:Male
  • Location:Venezuela

  • Calculators:
    algebra FX 2.0 plus
    Classpad 300

Posted 24 November 2007 - 04:00 AM

Why CpLua doesn't have a horizontal scroll???
When i uses this code
A={{1,2},{3,4}}
A[1][1]=6

for i=1,#A do
print(unpack(A[i]))
end
with a matrix 6 x 6 complex it show a desaster. The element of the same row continuo on the next line, it is confuse.

Thanks

#9 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 26 November 2007 - 11:28 PM

There is indeed no horizontal scrollbar in the Console window (that you see when you use the "print()" function")...

I would suggest you to try the UI package, there is a nice "mathedit" component that you might use to display mathematical expressions like matrices and CAS formulas :)

#10 Colombia

Colombia

    Casio Addict

  • Members
  • PipPipPip
  • 94 posts
  • Gender:Male
  • Location:Venezuela

  • Calculators:
    algebra FX 2.0 plus
    Classpad 300

Posted 16 February 2008 - 05:57 PM

I would suggest you to try the UI package, there is a nice "mathedit" component that you might use to display mathematical expressions like matrices and CAS formulas


Orwell, I read the "uifunction.txt" but I could not find the function than make this possible.
I learned how to create a window (ui.windows{...}) and included some text editable or not (ui.textedit{..}) and other things, but what is the function that allow me to call the matrix?

Thanks!!!

#11 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 16 February 2008 - 09:53 PM

Orwell, I read the "uifunction.txt" but I could not find the function than make this possible.
I learned how to create a window (ui.windows{...}) and included some text editable or not (ui.textedit{..}) and other things, but what is the function that allow me to call the matrix?

Thanks!!!

You can try something like this to display a matrix (or any other CAS expression):
require "ui" "cas"
local win, me

win = ui.window({name="Test", x=3, y=3, width=154, height=180})

me = ui.mathedit({x=0, y=0, width=152, parent=win})

me:setexpr(cas("[[1,2][3,4]]"))

ui.button({text="Quit", x=122,y=79, parent=win, 
  _clicked = function(self) ui.stop() end})

win:show(true)
ui.start()


#12 Colombia

Colombia

    Casio Addict

  • Members
  • PipPipPip
  • 94 posts
  • Gender:Male
  • Location:Venezuela

  • Calculators:
    algebra FX 2.0 plus
    Classpad 300

Posted 17 February 2008 - 02:43 AM

I copy to the CPLua on my PC and works but on my ClassPad doesn`t.

attempt to call field "mathedit" (a nil value)

#13 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 17 February 2008 - 07:46 PM

Are you sure you have the last version (0.9E)? :huh:

#14 Colombia

Colombia

    Casio Addict

  • Members
  • PipPipPip
  • 94 posts
  • Gender:Male
  • Location:Venezuela

  • Calculators:
    algebra FX 2.0 plus
    Classpad 300

Posted 17 February 2008 - 10:12 PM

ohhhhhhhh, I have the 0.9D.

Thanks

#15 sadjad

sadjad

    Newbie

  • Members
  • Pip
  • 1 posts

  • Calculators:
    classpad330

Posted 06 June 2013 - 05:11 AM

how can i work with matrix on lua??
i mean i wanna run a program and i need to know how can i write some matrix?
for example 3*3 such as :
3 3 3
2 7 9
1 3 11

#16 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 06 June 2013 - 08:04 AM

Hello sadjad and welcome to UCF! You should introduce yourself.

There are already answers in the previous posts. It would look like M = { {3, 3, 3} , {2, 7, 9} , {1, 3, 11} } but I doubt you want to do that because matrix multiplication, etc need additional code. However LNA (download link) has some Matrix functions.

Alternatively you can use CP's native matrix handling like Orwell showed in post #11 in this topic.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users