Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (howardR), 1,065 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Pretty Good Calculator #370861
05/16/11 11:24
05/16/11 11:24
Joined: Dec 2000
Posts: 4,608
mk_1 Offline OP

Expert
mk_1  Offline OP

Expert

Joined: Dec 2000
Posts: 4,608
Since Matlab is expensive, GNU Octave takes too long to start and the Windows(tm) Calculator ... well ... sucks ... I decided to write my own one, which now needs some testing.

http://mk-scape.de/down/pgc.zip

It still doesn't support anything I want but this is going to change in the future. Right now you can do all basic calculations and also use vectors/matrices by placing theirs comonents in parenthesis:
Code:
(1,2,3) vector or (1,2;3,4) 2x2 matrix


You can assign values to variables by using = or forward arrow
Code:
a = 3
3 -> a


There are some basic functions implemented. Descriptions are available by typing
Code:
help(function_name)


Trigonometric functions are in radians, I'm going to add a DEG/RAD switch later on.

You can copy the ans(wer) value to the clipboar by pressing Ctrl+P.

Vector multiplication: There are two different operators which can be used.
Code:
(1,2,3) * (3,4,5)' does a dot product. Please note that the second vector is transposed using an apostrophe.

(1,2,3) .* (3,4,5) does a component wise multiplication

.

You can create a vector of increasing values by using the range operator:
Code:
x = 0:255   Create vector of length 256 filled with all numbers from 0 to 255

x = 0:0.5:10 Create a vector from 0 to 10 with steps of 0.5, i.e. (0, 0.5, 1, 1.5, ...)



You can also plot functions but the plot window isn't really done yet and only displays graphs in the range -4 to 4 in x and y. Example:
Code:
x = -4:0.05:4
y = plot(sinh(x);cosh(x);tanh(x))



Operators:
Code:
+ add
- sub
* mul
/ div
! factorial
= assign to left
-> assign to right
^ power
, column delimiter
; row delimiter
x:y range
x:y:z range with steps unequal 1



Feel free to report any bugs here.

Last edited by mk_1; 05/16/11 11:35.

Follow me on twitter
Re: Pretty Good Calculator [Re: mk_1] #370862
05/16/11 11:32
05/16/11 11:32
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
How can i plot then?
Looks good!


Click and join the 3dgs irc community!
Room: #3dgs
Re: Pretty Good Calculator [Re: mk_1] #370863
05/16/11 11:34
05/16/11 11:34
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
draws 50% cpu all time, hangs on exit. i'd also interchange .* and *. also, suggestion popup menu does not show up properly, it re-disappears immediately. i think i'll stick with mathematica wink.

Re: Pretty Good Calculator [Re: Joey] #370864
05/16/11 11:37
05/16/11 11:37
Joined: Dec 2000
Posts: 4,608
mk_1 Offline OP

Expert
mk_1  Offline OP

Expert

Joined: Dec 2000
Posts: 4,608
Sorry, missed "plot", I edited my first post.
I just noticed it takes 50% cpu time, will change that. Why change .* and *. ? Most people are used to it from matlab. Popup menu disappears instantly because it shouldn't be displayed in the first place. I know all of these problems.

It's more about if all the functions and operators work properly.


Follow me on twitter
Re: Pretty Good Calculator [Re: Joey] #370865
05/16/11 11:39
05/16/11 11:39
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
One thing seems missing from the operators:

% modulo


"Yesterday was once today's tomorrow."
Re: Pretty Good Calculator [Re: Inestical] #370868
05/16/11 11:51
05/16/11 11:51
Joined: Dec 2000
Posts: 4,608
mk_1 Offline OP

Expert
mk_1  Offline OP

Expert

Joined: Dec 2000
Posts: 4,608
I'm going to add modulo, totally forgot that.

What this is really about is to type in all the stuff and then export this to LaTeX / MathML. I also used it to create look up tables for a µC. Vectors/Matrices are automatically transformed into valid C code.


Follow me on twitter
Re: Pretty Good Calculator [Re: mk_1] #370873
05/16/11 12:36
05/16/11 12:36
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Sounds interesting. Did you check out freemat? http://freemat.sourceforge.net/

Re: Pretty Good Calculator [Re: Xarthor] #370876
05/16/11 12:53
05/16/11 12:53
Joined: Dec 2000
Posts: 4,608
mk_1 Offline OP

Expert
mk_1  Offline OP

Expert

Joined: Dec 2000
Posts: 4,608
The biggest difference to all available calculators out there is the fact that you can choose any precision you want and are not restricted to 128bit values.

EDIT: fixed cpu problem. Included in next update along with modulo and any other bug you can find.

Last edited by mk_1; 05/16/11 12:54.

Follow me on twitter
Re: Pretty Good Calculator [Re: mk_1] #370891
05/16/11 15:32
05/16/11 15:32
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
.* sounds like "dot product", while * is the common product on the field. also, matlab seemed very inconsistent to me from what i've heard (especially when it comes to naming and function arguments).

what about python? you could use its power and write a latex/mathml exporter for the command line history. just a thought. i don't want to discourage you.

edit: mathematica (and python, by the way) has arbitrary precision.
edit2: and mathematica has latex and mathml output. don't you get a license at your university?

Last edited by Joey; 05/16/11 15:42.
Re: Pretty Good Calculator [Re: Joey] #370893
05/16/11 15:49
05/16/11 15:49
Joined: Dec 2000
Posts: 4,608
mk_1 Offline OP

Expert
mk_1  Offline OP

Expert

Joined: Dec 2000
Posts: 4,608
You don't. I wrote this for me so I don't care. wink
You are right that .* sounds like a dot product but since multiplication is not the only operator that can be used component wise it makes sense. You can e.g. use x.^2 on a matrix or divide each component by using ./

I like Python but it doesn't support matrices if you don't add NumPy and there's still a restriction on precision which applies to all calcs I know so far. It makes performing big matrix operations a lot slower but I can live with that as long as the results are as precise as I need them.


Follow me on twitter
Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1