flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Calculator for Win32

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
dmitriy566



Joined: 19 Jun 2012
Posts: 27
Location: Saint-Petersburg, Russia
dmitriy566
Hello!
Thank for answer. I try it and i see this function works really fast. Is it planned to add really symbolic calculations and not limited precision(for example 100 and 1000 digits after point). Or for example extend the base of special functions this program can evaluate. I have some code in fortran that can be able to solve functions and evaluate some special functions(LegendreP, BesselJ, Gamma, 2F1, AppelF4) and take integrals numerically(Gauss integrate). I plan to add new functions and improve existing. I think this can be adopted to assembler with some changes.
Post 18 Oct 2012, 09:19
View user's profile Send private message Reply with quote
dmitriy566



Joined: 19 Jun 2012
Posts: 27
Location: Saint-Petersburg, Russia
dmitriy566
Here is my code.
auger.f90 -- calculation of auger recombination in quantum dots
clebsch.f90 -- calculation of resonant energy transfer
mathlib.f90 -- you see what is it.


Description:
Download
Filename: send.rar
Filesize: 11.9 KB
Downloaded: 409 Time(s)

Post 18 Oct 2012, 09:34
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
tthsqe, I don't know either, but it is not needed, you should probably have something like a keyword "memoize" so you can tell the compiler/interpreter that it must maintain a dictionary, where the key are the inputs (parameters and any non-local variable), and the value is what the function returns. If a match is found, the call is not made, otherwise, the call is made and the inputs and return value are inserted into the dictionary.

This reduces the time complexity of Fib to O(n) effortlessly, and also helps on others recursive functions where devising an iterative method is not trivial (or not worth the coding effort for the one-time use).
Post 18 Oct 2012, 18:49
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 721
tthsqe
Hey - it is nice to see someone else working with hypergeoetric functions. I'm assuming you are doing some physics calculations - how do you use the Appell F4 there?

Right now each entity handled by the calculator fits in a fixed 256 bits.
Extending the evaluator to work with arbitary sized numbers would definitely slow it down a bit, but it would definitely add to the functionality of the calculator
Post 18 Oct 2012, 19:08
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 721
tthsqe
So I'm in the middle of reworking the program and have some comments for the people here.

LocoDelAssembly,
memoization is good to go for one variable integer functions - f[n] computes in O(n).

hopcode,
it would be trivial to rewrite the plotting/parsing functions as a dll and have it return, say, a pointer to the array of triangles/normals. (is this what you are talking about?)
However, if you want to preserve the state of the calculator between calls, the whole calculator machine would have to be put in a dll. (another interesting idea)

dmitriy566,
If you could explain how to calculate those functions and/or write some asm code for them, I could add them. (should work for all complex arguments)
Post 12 Nov 2012, 23:41
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
1) avoid memoization now. it is abstract. for it consider now
only an eventual implementation of hash and lookup tables.

2) because on float values approximation matters, you should think
carefully where/whether to use those LUT, but all this in a later
time.

it doesent matter it is slow now.
focus on the RPN parser is of importance. all should be done on the stack.
the stack can expressions of several miles Smile

3) each token should evaluates to a fixed record: example

INSTR/TYPE/SYMBOL 4 byte
VALUE/RESULT/ETC 8 bytes (qword)

it is not a waste of space, granted 100% ! you will
appreciate that 12 bytes record as soon as you start debugging it,
and for several other reasons, like design extension.

every calculation has a parametric state, i.e an istance.
client app feeds the instance again to the engine embedded
in a DLL or implemented as lib. calculation/plotting goes further on it.

Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 13 Nov 2012, 06:15
View user's profile Send private message Visit poster's website Reply with quote
dmitriy566



Joined: 19 Jun 2012
Posts: 27
Location: Saint-Petersburg, Russia
dmitriy566
Hello!
Now i am writing a explanation about my functions. I can explain briefly what i do.
First, you should write a function that provides Gauss integrate. To do this, you should have a function LegedreP(a polynom) and find its zeros. To calculate LegendreP you should use recurrent expression which can be found in my file(we have P0 and P1 and calculate next orders of Pn). Next, you shold write a function that finds a zero between a and b. It can be done by approximation a fuction of a parabola and finding its roots by known expression(next you should use an iteration procedure). Next you should write a function that founds a i-th root in [x0,x1]. It can be do easyly. Note, that in fortran arguments are passed by pointer, so we have a pointer to function and vars. Next, we have some integral expressions for a special functions(BesselJ and other). Note that sjn is a spherical Bessel function wich is calculated by iteration procedure for a big values and by series for a small values(this is done to increase a precision). So you have integral expressions which can produce a special function. Note that these integral expressions are not applicable at all complex values, so it is difficult to calculate special functions at all complex values. I calculated these functions at real values. Although i have a AppelF4 and 2F1, these functions are calculated below some radius in complex plane by a series. At higher values we need analythic expansion and it is difficult. Note that integral exponenta Ei(x) is taken as integral of main value(exclude zero point). So you should be accurate to reach enough precision. Also, i have a ClebschGordan coefficients, they can be calculated by a formulas in my program. Also you should note that i return a NaN in IEEE format if something goes wrong. If i find to say something else, or you can ask me, i'll explain.
Post 22 Nov 2012, 08:14
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 721
tthsqe
I have a question for those who are familiar with windows:

How can i have each call to a plotting function open up a new window that contains the graphics? For example, calling two plotting functions in the same command should open two new windows.

I currently have one fixed plotting windows that get over written when a new plot is made.


Also, should this thread get moved projects/ideas?
Post 08 Dec 2012, 17:31
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
It should indeed and it is now.
Post 08 Dec 2012, 18:13
View user's profile Send private message Reply with quote
Lummis



Joined: 25 Nov 2012
Posts: 15
Location: Canada
Lummis
I am grateful for your code, for I just got back to Assembly and this is just fantastic, someting I wanted to do and expand upon... It is a fine building bloc and learning tool.
I intend to work on it for sure, am doing so now - redoing the style of .asm document
as I read it and 'get an understanding' of it.
It has a form of 'command' interpreter, which is what we need for formulas or code for a 'new language' or whatever... Want to add a Lot of Science data, formulas, algos. (AI, etc.) into this project. One could include a web browser and 'spider', etc. into, an all-in-one program of sorts. Am I making sense to you?

Assembly Langugue Level Artificial Intelligence and Mathematical & Scientific program
" ALLAIMS " (as a tentative Name).

User input could be written in a file, and so could the examples, for reference and reuse.
Post 09 Dec 2012, 13:34
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 721
tthsqe
well then, welcome lummis
If I were going by what you just wrote, I would say the following:
- try if you like to decipher the source, but it might be difficult as I didn't leave any hints about the data structures used, ect. (its a mess, and the labels might not be the most logical ones)
- the user input is compiled to a 'virtual machine', and I am in the process of making this machine more flexible and able to handle arrays
- I'm all for adding more algorithms and data types
Post 10 Dec 2012, 01:01
View user's profile Send private message Reply with quote
Lummis



Joined: 25 Nov 2012
Posts: 15
Location: Canada
Lummis
I'm >1/2 through my first, aethethic, edit of your file, uploading when finished.

At Lines(*) 4519 & 4523: could you explain the ; ?
Quote:

...
fld st0
fadd st0,st4
fstp tword[p2+10*0]
fstp tword[p1+10*0]
fld st0
;fadd st0,st4
fstp tword[p2+10*1]
fstp tword[p1+10*1]
fld st0
;fadd st0,st4
fstp tword[p2+10*2]
fstp tword[p1+10*2]
fstp st0
...
Post 11 Dec 2012, 00:38
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 721
tthsqe
oh man, that contour plotting algorithm must look really cryptic.
Here is what is going on:

the cuboid is divided into a bunch of cells whose total number is u_div*v_div*w_div

Next, I see if the function changes sign along each edge, if it does, the subdivide function finds a point on the edge where this sign change happens.
this point and any other such points on the other edges of the same cube are then combined in some triangles.

For your question,
at those points in the code, certain coordinates are being incremented
and I put the dummy ; fadd st0,st4
just to make clear which coordinates are being incremented.

As you can see, my comments are not very informative.
The next version will be much better in terms of functionality and readability.
Post 11 Dec 2012, 06:20
View user's profile Send private message Reply with quote
Lummis



Joined: 25 Nov 2012
Posts: 15
Location: Canada
Lummis
Ok so I finally edited your .asm file to my taste.
I did not .zip it, and it's in .txt format.
Please let me know how you like the style, and
more importantly what you have changed since the beginning
for I have not (really) modified anything in the coding yet. Thx!


Description: ("muMath" re-edited)
Download
Filename: ALLAIMS.txt
Filesize: 202.59 KB
Downloaded: 535 Time(s)

Post 12 Dec 2012, 03:14
View user's profile Send private message Reply with quote
Lummis



Joined: 25 Nov 2012
Posts: 15
Location: Canada
Lummis
I managed to "omit" a bracket, that's easy to fix, the includes point towards my preference... AND somehow I deleted a line of code I guess...
Yet, the STYLE / 'protocol' is the main point.
You can see 'the bug' when it runs, in the 2nd. example, it's probably somewhere in the middle-2/3 down of the code, during calculation.
Just just recently, I've been hobbyisting x86 after 27 years away from Assembly, so... I don't even have an appropriate parser & checker.
Post 13 Dec 2012, 12:42
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 721
tthsqe
you did miss a "]".
What bug are you talking about? it seems to run fine on the fibonacci example.

Just to let you know, I'll be soon finishing the next version with arrays, memoization, a more powerful language, a SSA-based optimizer, and a more readable source.

If you want to have fun, try to write a a small program that can evaluate a string like '2+3*(7-2)' and print '29'. That is how I got started.
Post 13 Dec 2012, 21:56
View user's profile Send private message Reply with quote
Lummis



Joined: 25 Nov 2012
Posts: 15
Location: Canada
Lummis
I've found a bit of stuff, for ex.:
http://www.gnu.org/software/gsl/design/gsl-design_toc.html
But also wondering how much of this, and the likes of:
'Numerical Recipies in C' one has to "convert" to .asm ... I'm a noob, but eager lol Rolling Eyes
Post 16 Dec 2012, 15:14
View user's profile Send private message Reply with quote
KevinN



Joined: 09 Oct 2012
Posts: 161
KevinN
cool
Post 07 Mar 2013, 06:45
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6032
Location: Poland
MHajduk
What a pity that I missed this thread a year ago Embarassed because it's one of the most advanced math-oriented applications written with FASM I've ever seen. What convinced me the most to it is that it has got a superb input-output processing (parsing the text input and producing graphics with OpenGL). Moreover it has got also a perfect documentation written with LaTeX. The whole impression it gives certainly proves that the author is a professional programmer with a solid academic background. Respect Image

I think I should study your source more carefully because some ideas are for sure very interesting and worth deep analysis. Smile
Post 07 Mar 2013, 19:25
View user's profile Send private message Visit poster's website Reply with quote
Kedar



Joined: 21 Nov 2008
Posts: 16
Kedar
Hi tthsqe...cool muMath program, and especially thanks for the working example of VirtualAlloc I so needed. Just one question though: In your first use of VirtualAlloc, on line 898, won't the sub step back into memory that isn't part of what you've allocated?
Post 30 Apr 2013, 10:43
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.