Jump to content



Photo

Project: Cplua


  • Please log in to reply
858 replies to this topic

#161 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 21 September 2005 - 07:03 PM

This is not a bug... But I agree that you may find it strange. This is a "C-like" behaviour ;)

When you write "foo = {7,5}", you create a new table in the current scope, and you create the variable foo which is only a referent to this table. "foo" is not the table! It only points to it. Then when you write "a = foo", you only create a new referent for the same table. That means that changing the content of "a" (actually, the content of the table pointed by "a") is equivalent to changing the content of "foo" (same remark).
If you want to duplicate the table you must loop on it. As you said, you need loops for everything :rolleyes:
However if you wish I can quite easily create a "table.copy()" function :)

This is a bug, since the variable foo is not known inside sub(x). In general, foo has nothing to do with sub(x).

The variable "foo" is indeed not known, but "x" points to the same table (and not on a copy)...
Take a look on the 2.5 chapter of the book:

Tables in Lua are neither values nor variables; they are objects. If you are familiar with arrays in Java or Scheme, then you have a fair idea of what we mean. However, if your idea of an array comes from C or Pascal, you have to open your mind a bit. You may think of a table as a dynamically allocated object; your program only manipulates references (or pointers) to them. There are no hidden copies or creation of new tables behind the scenes. Moreover, you do not have to declare a table in Lua; in fact, there is no way to declare one. You create tables by means of a constructor expression, which in its simplest form is written as {} (...)

Again, I can understand your reaction. But the fact that a single table can have several aliases is important in several situations ;)

#162 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 21 September 2005 - 07:34 PM

This is not a bug... But I agree that you may find it strange. This is a "C-like" behaviour ;)
When you write "foo = {7,5}", you create a new table in the current scope, and you create the variable foo which is only a referent to this table. "foo" is not the table! It only points to it. Then when you write "a = foo", you only create a new referent for the same table. That means that changing the content of "a" (actually, the content of the table pointed by "a") is equivalent to changing the content of "foo" (same remark).
If you want to duplicate the table you must loop on it. As you said, you need loops for everything :rolleyes:
However if you wish I can quite easily create a "table.copy()" function :)
Again, I can understand your reaction. But the fact that a single table can have several aliases is important in several situations ;)

Bah, C strange behavior again :knife:. I really hate the influence of C in other languages.
If I understood well, table variables in Lua are actually "pointers". Maybe this behavior could be useful in "several situations", but definitely not in Numerical Analysis, where pointers are almost useless. I have seen plenty of Numerical Analysis programs, and I can tell that using pointers is a rare exception.
Please, create that "table.copy" function. It will be extremely useful for my programs :bow:.

I accepted the fact that I need a loop to add a number to all the elements of a matrix, but this is really annoying and inacceptable. I should think twice before implementing numerical methods in Lua, since numerical methods are full of matrix operations. Unfortunately, I don't have any alternative, as far as ClassPad is concerned. But, believe me, I will never install Lua in my computer. It's powerful, but its matrix "support" is primitive, no, more than primitive, prehistorical!

#163 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 21 September 2005 - 07:46 PM

I accepted the fact that I need a loop to add a number to all the elements of a matrix, but this is really annoying and inacceptable. I should think twice before implementing numerical methods in Lua, since numerical methods are full of matrix operations. Unfortunately, I don't have any alternative, as far as ClassPad is concerned. But, believe me, I will never install Lua in my computer. It's powerful but its matrix "support" is primitive, no, more than primitive, prehistorical!

There is no basis matrix support at all in C and C++, simply because it is very simple to create its own system. And if you don't want to create it yourself, there are libraries for this ;)
But you seem to forget that I can create new types in CPLua, I said that I could try to implement a "matrix" type, and I didn't forget it :)

By the way:

I really hate the influence of C in other languages.

Do not forget that Lua is written in C, and it was created by C programmers. I'm not sure if it is possible to write a complete interpreter with Fortran for another language, without getting a nice headache. But I'm not a Fortran user so I don't know (and I don't criticize it neither) ^_^

#164 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 21 September 2005 - 08:31 PM

But you seem to forget that I can create new types in CPLua, I said that I could try to implement a "matrix" type, and I didn't forget it

I didn't forgot it, but I thought that you forgot it ;). I really need this matrix type, together with definitions for adding and multiplying matrices with scalars or other matrices. Of course, you can define all this stuff in Lua itself, but then you will reinvent the wheel. Do you think you will implement that "matrix" type in a future version? If so, I can really make a huge Numerical Analysis library without the headache I have now... :plol:

Do not forget that Lua is written in C, and it was created by C programmers. I'm not sure if it is possible to write a complete interpreter with Fortran for another language, without getting a nice headache. But I'm not a Fortran user so I don't know (and I don't criticize it neither) ^_^

Well, you can do it in Fortran 95, but, as you said, it's really difficult. I've seen even 3D games in Fortran. They use libraries, exactly as C uses libraries for simple mathematics :rant:.

#165 unique33

unique33

    Casio Freak

  • Possibly hacked
  • PipPipPipPip
  • 229 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    classpad 300 , fx5500

Posted 21 September 2005 - 08:32 PM

I downloaded the Cplua Program set 1
but it does not include recsurfg !

If the 3D programs was faster they would be so usefull , because ClassPad doesn,t have the cylindrical and spherical coordinates in the graph window .

If you add a plot function to CPlua it will be so useful too .

#166 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 21 September 2005 - 08:35 PM

I didn't forgot it, but I thought that you forgot it ;)

It requires a lot of time, and I'm a little busy for now. Unfortunately the development of CPLua will be slightly slower than during hollydays :(

#167 unique33

unique33

    Casio Freak

  • Possibly hacked
  • PipPipPipPip
  • 229 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    classpad 300 , fx5500

Posted 21 September 2005 - 09:41 PM

I wrote a function for Laplace transform , but it is simple , it is just the definition of Laplace transform.
did anyone work on Laplace transform ?

my Laplace transform function is slow because it uses the nested Piecewise function !
but with one statment functions in classpad there is no ather choice.

now with Cplua we will have the capability to write multi statment functions
and I think it,s the time to start to work on it .

#168 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 21 September 2005 - 09:47 PM

Indeed I think that several enginering tools could be implemented in CPLua :)
Any volunteer? :lol:

#169 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 22 September 2005 - 10:06 PM

Just a few words to say that CPLua 0.7 is on good way :rolleyes:
I've finished most of the major improvements that I wanted to make. Now I will work on the libraries to add some new functions (complete the cas package e.g) :)

#170 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 22 September 2005 - 10:11 PM

Just a few words to say that CPLua 0.7 is on good way :rolleyes:
I've finished most of the major improvements that I wanted to make. Now I will work on the libraries to add some new functions (complete the cas package e.g) :)

If you have some time, give us more information about the new features. What functions are you planning to add? What do you mean by "complete the cas package"? I really want to know. ;)

#171 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 23 September 2005 - 05:45 PM

If you add a plot function to CPlua it will be so useful too .

Actually, I'm currently working on a Lua library for plotting functions or data. For now, the library contains functions for plotting (1) one or more functions, or (2) one or more data sets. The functions in this plotting library are highly configurable: you can set axes, tics, gridlines, linetypes, pointtypes etc, or you can let the library to automatically set values for all these settings (autoscaling was the most difficult part of this work). I started this plotting project because I wanted to visualize the results obtained by my Numerical Analysis functions included in LuaNumAn. Believe me, the result is impressive: you can plot a set of functions and data in about one second; in other words, plotting functions written in Lua are faster than the ClassPad built-in plotting functions. I can't understand why built-in functions are actually slower than my Lua functions, but it's true. All example programs in LuaNumAn now plot the results in various ways. Unfortunately, I can't post some screenshots here to see for yourself :(. It's really amazing that you can do all these things in an interpreted language, and you can do it fast.
I'm now working on some refinements in the plotting library functions, such as implementing minor tics and gridlines (currenlty, I have implemented only major tics and gridlines). After that, I'm plannining to upload the library as a stand-alone library, or as part of the LuaNumAn library, I'm not really sure yet.

Some remarks concerning CPLua plotting abilities:
(1) The only thing I can't add yet in my plotting functions is tic labels, since CPLua doesn't have a function for writing text in the graph window. Orwell, can you add this feature?
(2) If you plot directly on the graph window (draw.onscreen()), some lines and/or points are not shown. This bug appears quite often. On the other hand, if you plot everything in the buffer (draw.onbuffer()), then you visualize it by draw.update(), everything is fine. Anyway, I'm sure that Orwell knows this bug.

#172 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 23 September 2005 - 06:45 PM

If you have some time, give us more information about the new features. What functions are you planning to add? What do you mean by "complete the cas package"? I really want to know. ;)

The functions I added are

* waitkey(): Make the ClassPad return in Idle state while waiting for a key press. This is quite more efficient than writing "repeat until testkey()" because
- when you execute a loop like "repeat ... until ..." the interpreter is running, thus you are draining your batteries much faster than in Idle state;
- you may specify several keys as arguments to waitkey(), and this function will only return after one of those keys was pressed, so this is more convenient :)

* waitpen(): Same as waitkey()... but for the pen ;)

* input(): open a blank text field at the bottom of the console window, wait for the user to enter a string in it, and return the string. :D
Now you can write
print("Enter your name:")
name = input()
print("Hello, " .. name .. "!")

* table.copy(): returns a copy of the table given as argument.


In fact I've changed a lot of things in the program, not really on the interpreter. This is what you can see when launching CPLua 0.7:
Posted Image

" :huh: Huh? "Interactive"? What's that? :o"

:P
Well, this is the interactive mode :lol2: With this mode you can use exactly the same functions and features, but it executes each line directly so you don't have to write a new script to perform a simple operation with Lua. :) Take a look on this:
Posted Image

I would like to add some new functions to the CAS, and also the "call" ability for CAS expressions. And the "io" package is currently disabled, I think I will reactivate some useful functions (like formatted input/output etc) :)


Actually, I'm currently working on a Lua library for plotting functions or data. For now, the library contains functions for plotting (1) one or more functions, or (2) one or more data sets. The functions in this plotting library are highly configurable: you can set axes, tics, gridlines, linetypes, pointtypes etc, or you can let the library to automatically set values for all these settings (autoscaling was the most difficult part of this work). I started this plotting project because I wanted to visualize the results obtained by my Numerical Analysis functions included in LuaNumAn. (...) I'm now working on some refinements in the plotting library functions, such as implementing minor tics and gridlines (currenlty, I have implemented only major tics and gridlines). After that, I'm plannining to upload the library as a stand-alone library, or as part of the LuaNumAn library, I'm not really sure yet.

Actually I was thinking about creating a similar function (as a C library), so it could be even faster :nod:
But it's a good thing that you are already working on it, maybe I will try to convert your code in C later ^_^

Some remarks concerning CPLua plotting abilities:
(1) The only thing I can't add yet in my plotting functions is tic labels, since CPLua doesn't have a function for writing text in the graph window. Orwell, can you add this feature?

This is planned. I think I will use the Vector font, so you could even choose the size of the text to draw :)

(2) If you plot directly on the graph window (draw.onscreen()), some lines and/or points are not shown. This bug appears quite often. On the other hand, if you plot everything in the buffer (draw.onbuffer()), then you visualize it by draw.update(), everything is fine. Anyway, I'm sure that Orwell knows this bug.

I'm not totally surprised but I don't really know where the problem comes from :huh: Thanks for the report, I will take a look ;)

#173 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 23 September 2005 - 07:23 PM

* waitkey(): Make the ClassPad return in Idle state while waiting for a key press. This is quite more efficient than writing "repeat until testkey()" because
- when you execute a loop like "repeat ... until ..." the interpreter is running, thus you are draining your batteries much faster than in Idle state;
- you may specify several keys as arguments to waitkey(), and this function will only return after one of those keys was pressed, so this is more convenient :)
* waitpen(): Same as waitkey()... but for the pen ;)
* input(): open a blank text field at the bottom of the console window, wait for the user to enter a string in it, and return the string. * * table.copy(): returns a copy of the table given as argument.

Good news, especially the table.copy function :). I think I will stop developing LuaNumAn until version 0.7 will be released.

Well, this is the interactive mode :lol2: With this mode you can use exactly the same functions and features, but it executes each line directly so you don't have to write a new script to perform a simple operation with Lua. :)

Quite similar to the "interactive" mode available in many programs (Matlab. Octave, gnuplot etc). Useful if you want to try a new idea quickly. Interactive mode could be useful for debbugging too, provided that the user will be able to pause script execution, and enter the interactive mode to inspect the values of variables. Can you add functions such as pause and resume for this?
The new interface looks very nice too, although it needs some vertical centering ;).

And the "io" package is currently disabled, I think I will reactivate some useful functions (like formatted input/output etc) :)

I think you can easily add a "printf" function for formatted printing. Of course, such a function (similar to C's printf) can be implemented in Lua very easily:

function printf(form,...)
print(string.format(form,unpack(arg)))
return
end

but I think that the print function should be replaced by printf anyway...

Actually I was thinking about creating a similar function (as a C library), so it could be even faster. But it's a good thing that you are already working on it, maybe I will try to convert your code in C later ^_^

The code is yours if you want, I have only to make some refinements first. The graphs you can make with my plotting library are really nice. If I only was able to post some screenshots...

This is planned. I think I will use the Vector font, so you could even choose the size of the text to draw :)

Wow. With this feature, I can make plots of functions or data better that the built-in plotting functions.

#174 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 23 September 2005 - 08:00 PM

I already thought about a debugging mode, and SoftCalc suggested it too... But I didn't know how to present it - the implementation is not such a big deal. You are right, using the interactive mode with pause/resume (like Matlab) is a nice idea. I was thinking about a real debugger, where you can trace the prog step by step etc, but maybe the pause/resume system will be enough :)

Note: I just figured out how the vector font is encoded. I think I will customize it a little ^_^

#175 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 23 September 2005 - 09:19 PM

I already thought about a debugging mode, and SoftCalc suggested it too... But I didn't know how to present it - the implementation is not such a big deal. You are right, using the interactive mode with pause/resume (like Matlab) is a nice idea. I was thinking about a real debugger, where you can trace the prog step by step etc, but maybe the pause/resume system will be enough :)

I agree, pause/resume is enough for debugging, plus it seems to be easily implemented. A real debugger is certainly useful, but we can live without it, at least for now. Btw, when you are planning to release version 0.7?

#176 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 23 September 2005 - 09:23 PM

I don't exactly know when this version will be released... There are still many things to add, but I think it can wait until a next version ;)
I'll try to finish the 0.7 version tomorrow (but I said "I'll try" :rolleyes: )

#177 unique33

unique33

    Casio Freak

  • Possibly hacked
  • PipPipPipPip
  • 229 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    classpad 300 , fx5500

Posted 23 September 2005 - 09:35 PM

Actually, I'm currently working on a Lua library for plotting functions or data. For now, the library contains functions for plotting (1) one or more functions, or (2) one or more data sets. The functions in this plotting library are highly configurable: you can set axes, tics, gridlines, linetypes, pointtypes etc, or you can let the library to automatically set values for all these settings (autoscaling was the most difficult part of this work). I started this plotting project because I wanted to visualize the results obtained by my Numerical Analysis functions included in LuaNumAn. Believe me, the result is impressive: you can plot a set of functions and data in about one second; in other words, plotting functions written in Lua are faster than the ClassPad built-in plotting functions. I can't understand why built-in functions are actually slower than my Lua functions, but it's true. All example programs in LuaNumAn now plot the results in various ways. Unfortunately, I can't post some screenshots here to see for yourself :(. It's really amazing that you can do all these things in an interpreted language, and you can do it fast.
I'm now working on some refinements in the plotting library functions, such as implementing minor tics and gridlines (currenlty, I have implemented only major tics and gridlines). After that, I'm plannining to upload the library as a stand-alone library, or as part of the LuaNumAn library, I'm not really sure yet.


does your plot function support 3D ploting ?
is it possible to have the 3D ploting in rectangular and cylindrical or spherical coordinates, but the fast ones ?
If your plot library will contain this feathers it will be surprising !
:)
because we do not have this capibility in the classpad graph windows but it could be implemented
(the cylindrical and spherical coordinates) :(

#178 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 23 September 2005 - 10:08 PM

does your plot function support 3D ploting ?
is it possible to have the 3D ploting in rectangular and cylindrical or spherical coordinates, but the fast ones ?
If your plot library will contain this feathers it will be surprising !
or spherical coordinates, but the fast ones ?
If your plot library will contain this feathers it will be surprising !

Not yet, it only supports 2D plots of functions and data (but really nice plots!). Programs for 3D plotting aren't so difficult to implement, but their computation time is obviously larger. However, I was afraid that 2D plots implemented in Lua will be slow too, but I was wrong. Maybe even 3D plots will be fast, I'm everyday surprised by Lua speed in Numerical Analysis programs (given that it runs on a calculator, of course). Anyway, I started this plotting library for visualize numerical results obtained by LuaNumAn, were, for now, I don't need 3D plots. Maybe I'll try a small example of 3D plotting, and if it is fast enough, I will implement some 3D plot support, but this has a low priority for me, given that LuaNumAn needs more methods to be added.

I think that you mean plotting in Cartesian coordinates, but for functions expressed in spherical or cylindical coordinates. This is not difficult at all, it simply needs transformation from one system to the other. Plotting in pure spherical or cylindical coordinates isn't difficult as well (for example, a cylinder is plotted as a plane in cylindical coordinates).

#179 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 23 September 2005 - 10:13 PM

What about a C library for 3D graphics? :P

#180 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 23 September 2005 - 10:31 PM

What about a C library for 3D graphics? :P

Interesting, but not much. I will certainly not do it for two reasons: first, I don't like C (I know that you already know it). Second, there are more interesting things that should be implemented. I wish that you will not do it as well, since this will slow down the developement of CPLua <_<.
Btw, do you have any explanation for the fact that a Lua program can plot functions (with axes, tics, gridlines etc) much faster than the ClassPad built-in plotting functions? The time needed by my Lua program to plot 4 functions is less than the time needed to plot x^2 in the "Graph" application. I can't believe that they were not able to write a fast program for this, and I cannot see how the Lua interpreter can do this faster than a built-in machine language program. Really strange.

#181 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 23 September 2005 - 10:38 PM

Interesting, but not much. I will certainly not do it for two reasons: first, I don't like C (I know that you already know it). Second, there are more interesting things that should be implemented. I wish that you will not do it as well, since this will slow down the developement of CPLua <_<.

I was joking. There are indeed several other priorities ;)

I don't exactly know why the Basic plot functions are that slow...
But there could be several reasons:
* evaluation of the expression for each plot
* use of BCDs as number type
* conversion from graph coordinates to screen coordinates
* drawing operation for each plot
* ...

#182 BiTwhise

BiTwhise

    Casio Overgod

  • [Legends]
  • PipPipPipPipPipPipPip
  • 627 posts
  • Gender:Male
  • Location:Guildford, Surry, UK
  • Interests:Programming, games, consoles, martial arts

  • Calculators:
    FX9700WE, CFX9970G, AFX2.0, Classpad 300

Posted 23 September 2005 - 10:42 PM

What about a C library for 3D graphics? :P


I wouldn't mind helping out a little bit with that, depending on how much time I'll have on my hands.

A simple set of C functions for creating buffers of vertices and indices, transforming them, and rendering them as different primitive types shouldn't be too much work.

Have you thought about sharing the sources for CPLua, so that other's can extend its functionality?

#183 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

Posted 24 September 2005 - 07:08 AM

I talked to 2072 and since you are doing quite some work here and have quite verbose in and output we could generate a "Projects" topic where this project gets and own sub forum. This topic could then be moved there.

(I also want an MLC2 subforum for the AFX project. This was the main reason for me to ask :P )

OK. If you want you can move this topic to the new forum.

#184 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 September 2005 - 07:53 AM

I don't exactly know why the Basic plot functions are that slow...
But there could be several reasons:
* evaluation of the expression for each plot
* use of BCDs as number type
* conversion from graph coordinates to screen coordinates
* drawing operation for each plot
* ...

I'm not talking about basic plot functions only, I' m talking about the built-in "Graph" application, except if this application is actually a Basic program; anyway, judging from Casio's "support" until now, even this can be true :banghead:. Conversion from graph to screen coordinates is done by any plotting program, so it cannot be a reason for reduced speed. But you are right, BCD arithmetics can be the reason, since the "Graph" application is able to do some numerical computations (root finding, maxima and minima) with great accuracy. To do that, it probably stores in memory a large table of function values, and this could be time consuming. Whatever the reason is, CPLua permits to write and use an alternative, capable to do many things more efficiently. The only serious thing that is missing is the CAS, but the first steps on this have been already done.
I'm not sure that you really understand what you started: it's a great project, and it has the potential to transform ClassPad to a great calculator, I can even say a "seriously programmable" PDA, more powerful than those "Word and Excel" machines you can find anywere nowadays. Despite the fact that programming in Lua has some disadvantages, we already know that you can even write "real-life" Numerical Analysis programs in CPLua, and the result is more than satisfactory. A month ago, before this project started, I couldn't even think to write such programs for my ClassPad.

I talked to 2072 and since you are doing quite some work here and have quite verbose in and output we could generate a "Projects" topic where this project gets and own sub forum. This topic could then be moved there.
(I also want an MLC2 subforum for the AFX project. This was the main reason for me to ask :P )
OK. If you want you can move this topic to the new forum.

Sounds good to me, but Orwell has to decide. If he agrees, my Lua project "LuaNumAn" should be moved in this sub-forum as well.
PS: I really like your avatar; maybe I should change mine to something similar.

#185 BiTwhise

BiTwhise

    Casio Overgod

  • [Legends]
  • PipPipPipPipPipPipPip
  • 627 posts
  • Gender:Male
  • Location:Guildford, Surry, UK
  • Interests:Programming, games, consoles, martial arts

  • Calculators:
    FX9700WE, CFX9970G, AFX2.0, Classpad 300

Posted 24 September 2005 - 10:51 AM

Slow graph plotting:
I believe the main reasons for the built in graph application to plot relatively slow would be a couple of things.
1) It probably evaluates the entire expression algebraically for every plot... This would be major slowdown on heavy expressions.
2) It refreshes the screen between every pixel plotted. This would cause some unecessary slowdown when evaluating simple expressions.

As for the root, min, and maxima finding, it would be pretty naive to think it stores tables of values for later use ^^. It would search for those, like any other numerical analysis. Besides, even if it did store off numbers for every plot in a table, that shouldn't impact performance much at all.


New subforum:
Sounds like a good idea. Or maybe, more genaral, a subforum for classpad projects.


CPLua:
A few wild suggestions/requests
What if we have wrappers in lua around all the Peg API, so we can write complete applications utilising everything available there, like menus, subwindows, message boxes, input boxes, etc... everything you could do with the full SDK, but scripted on the calcluator :)

Combine this with wrappers around all the CPExpression functionallity (which you're working on already, no?), and we could basically rewrite Main, and improve it. If we reproduce a full-blown Main equivalent in lua script (shouldn't be much slower, since the main work will be going on in the native expression evaluator), we could allow users to build functions in lua, that can be accessed from this application.

#186 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 September 2005 - 11:31 AM

Slow graph plotting:
I believe the main reasons for the built in graph application to plot relatively slow would be a couple of things.
1) It probably evaluates the entire expression algebraically for every plot... This would be major slowdown on heavy expressions.
2) It refreshes the screen between every pixel plotted. This would cause some unecessary slowdown when evaluating simple expressions.
As for the root, min, and maxima finding, it would be pretty naive to think it stores tables of values for later use ^^. It would search for those, like any other numerical analysis. Besides, even if it did store off numbers for every plot in a table, that shouldn't impact performance much at all.

Maybe you are right, it does not store a table of function's values, but evaluating the entire expression algebraically or refreshing the screen between every pixel plotted is naive as well ;). Furthermore, your statement about Numerical Analysis is not correct: Most (to be precise, almost all) numerical methods use matrix operations on large tables. Maybe this is not true on finding maxima or minima (although there are maxima-finding methods that do that), but your conclusion concerning "any other numerical analysis" is totally wrong.

#187 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 24 September 2005 - 11:32 AM

I think that a subforum will be nice, since there seems to be several persons intersted in CPLua's development :nod:

> Bitwhise : I plan to release the source code, but the problem is that it is not easy to present it in a fully modularized way... I'm doing my best, but I'm not an expert like PAP :lol: But don't worry it's coming ;)
About Peg's GUI: I was thinking about a "gui" package for this kind of things... It is indeed possible to wrap any functionality of the SDK in the Lua language, but the main problem is that the SDK is object oriented, and Lua is not <_< So it gets a little bit tricky sometimes :rolleyes:

I agree that giving the possibility to the user to create Lua functions and then call it from Basic is great, but that means that the interpreter must be callable from anywhere... and what about the input/output problems? <_< For example, all drawing operations are made on a special window which is specific to the CPLua program, and those operations need to be redirected on the window used by the Basic program.
It is a nice idea, but it certainly won't be easy ;)

By the way, I've worked on the draw.text() function this morning, here is an overview:
Posted Image
This font isn't really nice and I want to customize it a little, but I will need to write a small program for that. I hope that you won't mind if I use this font in CPLua 0.7 and change it in the next version ;)

#188 BiTwhise

BiTwhise

    Casio Overgod

  • [Legends]
  • PipPipPipPipPipPipPip
  • 627 posts
  • Gender:Male
  • Location:Guildford, Surry, UK
  • Interests:Programming, games, consoles, martial arts

  • Calculators:
    FX9700WE, CFX9970G, AFX2.0, Classpad 300

Posted 24 September 2005 - 11:46 AM

(although there are maxima-finding methods that do that), but your conclusion concerning "any other numerical analysis" is totally wrong.

Sorry, didn't think about my wording of that one. Numerical approximations in evaluating algebraic expressions. For analysis that quickly converge from the given expression (like min, max, root), a table of values would be somewhat redundant.


> Bitwhise : I plan to release the source code, but the problem is that it is not easy to present it in a fully modularized way... I'm doing my best, but I'm not an expert like PAP :lol: But don't worry it's coming ;)
About Peg's GUI: I was thinking about a "gui" package for this kind of things... It is indeed possible to wrap any functionality of the SDK in the Lua language, but the main problem is that the SDK is object oriented, and Lua is not <_< So it gets a little bit tricky sometimes :rolleyes:

Yup, can't say I like the way lua does its OO too much =P
That said, in lua, everything is an object (or a table, in lua lingo), so you can do object oriented programming with it.

I agree that giving the possibility to the user to create Lua functions and then call it from Basic is great, but that means that the interpreter must be callable from anywhere... and what about the input/output problems? <_< For example, all drawing operations are made on a special window which is specific to the CPLua program, and those operations need to be redirected on the window used by the Basic program.
It is a nice idea, but it certainly won't be easy ;)

That's not quite what I was suggesting either.
I was saying, if we could write a lua application that replicates the functionality of Main, then this application could serve as a host for executing other lua functions, prefferably combined with normal classpad expressions.
I really see no reason to use Basic, when lua is avaible to us :)

#189 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 September 2005 - 11:53 AM

I think that a subforum will be nice, since there seems to be several persons intersted in CPLua's development :nod:

Let's move there then :).

I plan to release the source code, but the problem is that it is not easy to present it in a fully modularized way... I'm doing my best, but I'm not an expert like PAP :lol: But don't worry it's coming ;)

Releasing the source code is your decision. If you do it, be aware that modified (maybe buggy) versions may be released by others too, so you should publish the code under GPL; this enforces other developers to specifically state in their releases that they have modified your code, it is not the original, so it may not work properly.
About the "expert" thing: Ehm, if you mean it, thanks. I think I'm good on that. Afterall, if you use Fortran 95, it is almost imperative to write fully modularized programs <_<. But you are an experienced programmer too, you are just not accustomed to modular programming, because your computer is infected by C/C++ ;).

I agree that giving the possibility to the user to create Lua functions and then call it from Basic is great

This could be useful in rare cases. Afterall, who needs CP Basic anymore? :greengrin:

By the way, I've worked on the draw.text() function this morning.
This font isn't really nice and I want to customize it a little, but I will need to write a small program for that. I hope that you won't mind if I use this font in CPLua 0.7 and change it in the next version ;)

Wow. I have found a way to post screenshots of my Lua plotting library, but I will wait for version 0.7, just to add tic labels. I want version 0.7, and I want it now! :rolleyes:

#190 BiTwhise

BiTwhise

    Casio Overgod

  • [Legends]
  • PipPipPipPipPipPipPip
  • 627 posts
  • Gender:Male
  • Location:Guildford, Surry, UK
  • Interests:Programming, games, consoles, martial arts

  • Calculators:
    FX9700WE, CFX9970G, AFX2.0, Classpad 300

Posted 24 September 2005 - 12:00 PM

Releasing the source code is your decision. If you do it, be aware that modified (maybe buggy) versions may be released by others too, so you should publish the code under GPL; this enforces other developers to specifically state in their releases that they have modified your code, it is not the original, so it may not work properly.

You could also share the source with selected contributors without making it a public community project.
That way, those with intention of contributing can test their code on the full source, while all integration is performed by Orwell, and only he does the releases.

#191 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 September 2005 - 12:05 PM

Sorry, didn't think about my wording of that one. Numerical approximations in evaluating algebraic expressions. For analysis that quickly converge from the given expression (like min, max, root), a table of values would be somewhat redundant.

Indeed, it is redundant, but only in simple root-finding methods, such as Newton-Raphson or Brent, and only if your function is explicitly defined. If the function is not know, and you know its value is specific points, then you should use interpolation, even in simple root-finding methods. Furthermore, the function may be defined numerically (e.g., the Bessel functions, supported by ClassPad). In all these cases, you need plenty of table operations.

I was saying, if we could write a lua application that replicates the functionality of Main, then this application could serve as a host for executing other lua functions, prefferably combined with normal classpad expressions.
I really see no reason to use Basic, when lua is avaible to us :)

Sounds good, but I'm afraid that it will be hard to implement it.

Btw, if you are working in Lua and you accidentally press "Main" or "Menu", the Lua Add-In terminates, and you lose all unsaved work. Is there anyway to add a "Exiting Lua: Are you sure?" window to avoid this? I think that it will be easy to implement such a thing.

#192 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 September 2005 - 12:19 PM

You could also share the source with selected contributors without making it a public community project.
That way, those with intention of contributing can test their code on the full source, while all integration is performed by Orwell, and only he does the releases.

This is probably the best way to proceed, if the developer finally decides to release the source code.

Btw, BiTwhise, Jeg snakker norsk. Not too much, I make a lot of mistakes, so I cannot exactly speak in that language, but I understand nynorsk rather well. Bokmal is harder to understand, however.

#193 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 24 September 2005 - 12:36 PM

I was saying, if we could write a lua application that replicates the functionality of Main, then this application could serve as a host for executing other lua functions, prefferably combined with normal classpad expressions.

This is actually what I had in mind when I was implementing the "interactive" mode (or the "shell" if you prefer). It sure doesn't have all the functionality of the CP's Main mode, but you can use every feature of the interpreter :)


Btw, if you are working in Lua and you accidentally press "Main" or "Menu", the Lua Add-In terminates, and you lose all unsaved work. Is there anyway to add a "Exiting Lua: Are you sure?" window to avoid this? I think that it will be easy to implement such a thing.

Actually it is not that easy, because when the user presses one of those key the program doesn't receive a message like "The user want to quit the app, do you agree?" but rather "the application is closing, do what you have to do" so I'm not sure that I can cancel this order correctly. I will let you know :)

#194 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 September 2005 - 12:47 PM

Hmm, I don't use the SDK, I supposed that there was an "event" detecting that the user has pressed these keys, and a function declaring what to do if that event occurs.

Ehm, there is another annoying thing: If you close a file, the editor always asks for saving, even if the file is just saved. It would be better if the editor was able to detect that no change was made, so there is no need to ask for saving. But, if I remember well, you have not complete access to the editor's functionality, maybe it isn't easy to modify its behavior.

#195 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

Posted 24 September 2005 - 06:59 PM

I actually though BiTwhise would move it ...

anyways ... it is moved now.

#196 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 24 September 2005 - 07:16 PM

I actually though BiTwhise would move it ...

anyways ... it is moved now.

Thanks ;)

#197 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 September 2005 - 07:30 PM

I actually though BiTwhise would move it ... anyways ... it is moved now.

Yes, but my "LuaNumAn" topic, concerning a Numerical Analysis library written in CPLua, has not been moved. I think that this new sub-forum is the proper place for the LuaNumAn topic, so please move it here.

#198 Orwell

Orwell

    Casio Overlord

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

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 24 September 2005 - 10:01 PM

I'm sorry I won't be able to release the 0.7 version today... There are still a couple of things that I need to do. However tomorrow should be fine ;)

#199 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 September 2005 - 10:15 PM

I'm sorry I won't be able to release the 0.7 version today... There are still a couple of things that I need to do. However tomorrow should be fine ;)

I should wait till tomorrow then :(. I had visitors today, but I had kept an eye in the forum to see if the time has come. Anyway, a proverb in my native language says: "the good thing takes time" ;).
Btw, this is the most long-waited version. Blame University!

#200 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 25 September 2005 - 01:40 PM

There is a small bug concerning the keypad function. Suppose a program that uses keypad(0) to make the virtual keyboard invisible. The program prints something in the console window, it switches to the graph window, it plots some functions, then returns to the console window again, and terminates execution. Everything works as expected. However, when you press EXE after program execution, CPLua returns to the editor, but sometimes (not always) the bottom of the screen (where the keyboard was) remains blank, and the program listing is limited to the area available if the keyboard is active. This bug happens only if the keyboard is active just before program execution. I'm not sure, but I suspect that this behavior is directly related with the well-known bug concerning the scroll bar and the keyboard.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users