LiveCode Math Library

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ckaraca
Posts: 17
Joined: Mon Jan 30, 2012 10:43 am

LiveCode Math Library

Post by ckaraca » Thu Feb 02, 2012 2:43 pm

Hi again,
I discover LiveCode and it is still the best programming language for me.
I wonder , Does LiveCode support complex Math functions? (Foor example matrix calculation, transpose, inverse..)
If It has this capabilities , How I use these functions?
:roll:
Thanks for reply.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LiveCode Math Library

Post by FourthWorld » Thu Feb 02, 2012 4:16 pm

Some of these, like transpose, are in the language - see the dictionary.

There's also an old MetaCard library named joneslib.mc which has some useful stats functions, but it's not been updated in a while and has a few conflicts with the current set of language tokens. I've contacted the author to see if he'll allow me to distribute an updated version - I'll keep you posted.

In the meantime, the built-in functions may help get you started, and LiveCode's fast enough that most of the rest can probably be scripted with reasonable effort.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

ckaraca
Posts: 17
Joined: Mon Jan 30, 2012 10:43 am

Re: LiveCode Math Library

Post by ckaraca » Fri Feb 03, 2012 7:47 am

Thank you for helping.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LiveCode Math Library

Post by FourthWorld » Fri Feb 03, 2012 3:25 pm

While you're working your way through the built-in functions, I can give you an update on JonesLib:

The author, Dr. David L. Jones of University of South Florida, has granted me permission to update JonesLib to work with current versions of LiveCode.

I have some client deadlines to meet for the next several days so I'm not sure exactly when I'll be able to get to it, but I don't think it'll take too long once I do.

I'll drop a note here when it's available.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: LiveCode Math Library

Post by sturgis » Fri Feb 03, 2012 5:07 pm

Richard, while I don't have the math skills to track down any weirdness in that area of things, I grabbed the library and think I have things tweaked so that (hopefully) everything is now working.

Changed the name of transpose to transposeAFunc to remove the name conflict
Change the name of matrixmultiply to matrixmult to remove the name conflict
Adjusted sterr function to remove a variable naming conflict with livecode standarddeviation function.
Also set sterr to use the livecode standarddeviation but a simple comment change can revert to using the library stdv
My comments in the script are marked with ## at the start of each line.

I probably missed things (again do to a major lack of math skills) but hopefully this will save you a couple minutes when you get the time to check it.

The updated file is here: http://dl.dropbox.com/u/11957935/jonesLib.livecode
FourthWorld wrote:While you're working your way through the built-in functions, I can give you an update on JonesLib:

The author, Dr. David L. Jones of University of South Florida, has granted me permission to update JonesLib to work with current versions of LiveCode.

I have some client deadlines to meet for the next several days so I'm not sure exactly when I'll be able to get to it, but I don't think it'll take too long once I do.

I'll drop a note here when it's available.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LiveCode Math Library

Post by FourthWorld » Fri Feb 03, 2012 6:18 pm

Good work. I appreciate your efforts, but I'm still going to do a revision of my own to take advantage of some opportunities for optimization.

For compatibility, I'll use your version as a starting point.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Re: LiveCode Math Library

Post by kcorey » Fri Jun 15, 2012 1:41 pm

Hey Richard,

Was just wondering how you're getting on with the math library rewrite?

I'd love to be able to learn from your optimisations.

Thanks,

-Ken

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LiveCode Math Library

Post by FourthWorld » Fri Jun 15, 2012 4:36 pm

kcorey wrote:Was just wondering how you're getting on with the math library rewrite?
Thanks for the bump in this thread -- good reminder of one more thing on my to-do list. :)

You can blame my clients for the current delay - been a busy season here (though I'm certainly not complaining; it's a good problem to have).

And before I dive into joneslib I need to first finish an article for LiveCodeJournal.com documenting the format for the output of LC's arrayEncode function.

With any luck I'll be able to complete both of those within the next two weeks, but if you don't see a post from me to that effect you're welcome to rattle my cage at ambassador -at- fourthworld.com to make sure it doesn't fall off my plate. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: LiveCode Math Library

Post by mwieder » Fri Jun 15, 2012 5:20 pm

an article for LiveCodeJournal.com documenting the format for the output of LC's arrayEncode
! Muchly looking forward to that.
Post an update on the forum when you get that put together - LiveCodeJournal tends to get lost between the cracks and could use more publicity.

almmohd
Posts: 2
Joined: Sat Jul 13, 2013 6:38 pm

Re: LiveCode Math Library

Post by almmohd » Sat Jul 13, 2013 6:44 pm

I am completely new to livecode, I just downloaded the community version. How do I see the standard math functions available?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: LiveCode Math Library

Post by dunbarx » Sun Jul 14, 2013 5:11 am

Hi.

The best way is to use the dictionary. There is no filter there, however, for math functions and commands, So you have to pretty much find them yourself. But if you want to add two numbers, you might search for the "add" command, or the "+" operator. You get the point.

Of particular value to you might be the "see also" elements when you do find a math item. This will lead you to all sorts of others.

To find such things as "sqrt" or "matrixMultiply", you will need patience and luck. But they are all there. You can always ask here for particular things.

Craig Newman

almmohd
Posts: 2
Joined: Sat Jul 13, 2013 6:38 pm

Re: LiveCode Math Library

Post by almmohd » Sun Jul 14, 2013 2:00 pm

Thanks Craig, how do you utilize the library they were talking about in this post: JonesLib?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: LiveCode Math Library

Post by mwieder » Sun Jul 14, 2013 5:48 pm

Bump. Richard - has this indeed fallen off your plate?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LiveCode Math Library

Post by FourthWorld » Sun Feb 02, 2014 5:51 pm

mwieder wrote:Richard - has this indeed fallen off your plate?
Evidently. :) Or more specifically, I have the folder on my desktop and hilited in red to remind me to dive into that optimization when I have a chance, but this darn open source thing with LiveCode has been keeping my phone ringing with client work, so it's been idle way too long.

If anyone else has time to take a stab at it please do so.

In addition to the conventional things we might look for, like using "repeat for each..." instead of "repeat with.." and making sure loops have as much work done outside of them as possible, etc., there are some interesting notes on performance from Wil Dijkstra's posts to the old MC list that may be worth reviewing:

http://lists.runrev.com/pipermail/metac ... 04415.html
http://lists.runrev.com/pipermail/metac ... 04469.html
http://lists.runrev.com/pipermail/metac ... 04539.html

One of the things I learned from those is the impact of variable initialization on calculations. We often take such things for granted, but I've found in some recent work that I was able to boost performance of some handlers by as much as 30% when I passed variables by reference rather than by value.

A more subtle benefit can come from exploring different ways of doing arithmetic on vars as described in the third link above. Interesting how small things can add up.

Of course such changes need to be considered on a case-by-case basis, but worth keeping in mind when revising JonesLib.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”