Algebra

BlitzMax Forums/BlitzMax Beginners Area/Algebra

Zacho(Posted 2009) [#1]
Is there some free module or something that tells the compiler how to solve equations when it sees something like this:


[4((8*3.4/4)87]=4x



Or at least this:

[4((8*3.4/4)87]=4



plash(Posted 2009) [#2]
No, there is not.


Warpy(Posted 2009) [#3]
Do you want one?


xlsior(Posted 2009) [#4]
I thought that Brucey had a module that did this... the MuParser Module, perhaps? http://code.google.com/p/maxmods/ (Need SVN to download)


Zacho(Posted 2009) [#5]
@Warpy- I would love one if you are willing to give it to me. Or if there is just code because I'm unfamiliar with modules.


Warpy(Posted 2009) [#6]
What do you need this for, anyway?


Shambler(Posted 2009) [#7]
What do you need this for, anyway?


Shhhh..'tis secret. ;)


xlsior(Posted 2009) [#8]
Just double-checked: Yes, the muparser module does indeed do this.

Feed it an expression, e.g: "((10^3)+17)/2" and receive an answer: 508.5

For extra flexibility, you can even include blitzmax functions as part of the equation.


Zacho(Posted 2009) [#9]
ok, but how can i run this in my program?


xlsior(Posted 2009) [#10]
In case you don't know how to use SVN to download it from Brucey's page, I zipped up the specific folder and temporarily threw it on my site. You can download it here:

http://www.xlsior.org/temp/muparser.mod.zip

This one has been compiled for Windows -- if you are using a Mac or Linux, you'll need minGW to re-compile the module first before you can use it.

But anyway, under windows:
Navigate to your blitzmax installation folder:
c:\program files\blitzmax (Or whereever you installed it)
Go into the 'mod' folder, and create a bah.mod subdirectory if you don't already have it
The contents of the zipfile should be under a folder named c:\program files\blitzmax\mod\bah.mod\muparser.mod

You can find two examples in the blitzmax\mod\bah.mod\muparser.mod\examples folder.

When you wish to use any of the functions in your own program, make sure to import BaH.muParser at the top of your program.


Zacho(Posted 2009) [#11]
What exactly are the examples supposed to do? When I run them I get:
 C:/Program Files/BlitzMax/mod/bah.mod/muparser.mod/muparser.release.win32.x86.a(muParserBase.cpp.release.win32.x86.o)(.text$_ZNSt6vectorISsSaISsEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPSsS1_EERKSs+0x43c):muParserBase.cpp: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
C:/Program Files/BlitzMax/mod/bah.mod/muparser.mod/muparser.release.win32.x86.a(muParserBase.cpp.release.win32.x86.o)(.text$_ZNSt6vectorISsSaISsEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPSsS1_EERKSs+0x450):muParserBase.cpp: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'

Over and over for like 50 pages in the output tab

The only reason I got the code was to make a program that got user input then solved the equation.


Brucey(Posted 2009) [#12]
What version of BlitzMax do you have?

The error implies you are using an older version of BlitzMax than Xlsior compiled the module with. (technically... a different version of the MinGW linker supplied with BlitzMax)

Those particular examples demonstrate how it evaluates equations, as well as showing how you might use a BlitzMax function as part of the calculation.


Zacho(Posted 2009) [#13]
i have no idea atm which version i have


Brucey(Posted 2009) [#14]
In the IDE, open the About window. It should say there.


xlsior(Posted 2009) [#15]
Mine was compiled with the latest version, 1.33 RC5.

Zacho: You can download the latest version of Blitzmax by going to the 'account' tab at the top of the forum, and then going to 'product updates' and then download it from there.


Zacho(Posted 2009) [#16]
ok