Module for working with Vectors

Post and discuss Lemur Modules.
brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16
Module for working with Vectors

Post by brianc » 03 Dec 2012 01:31

I've just uploaded a module that contains a collection of functions for working with vectors. Examples include sorting, shuffling, adding items, removing items, getting every ith element, calculating the distance between vectors, and more. Hope it's helpful!

http://liine.net/en/community/user-library/view/330/
Attachments
SLVectorScreenshot.png
SLVectorScreenshot.png (19.31KiB)Viewed 5093 times

Joe Soap
Regular
Posts:475
Joined:07 Jul 2012 15:04

Re: Module for working with Vectors

Post by Joe Soap » 03 Dec 2012 19:19

Hey brianc, that does look useful - many thanks. :)

Is this part of the "learning curve about to drop" or is it just a coincidence that several instructional-type modules have been uploaded by forum members in the last few days?

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: Module for working with Vectors

Post by brianc » 03 Dec 2012 20:47

Joe Soap wrote:Is this part of the "learning curve about to drop" or is it just a coincidence that several instructional-type modules have been uploaded by forum members in the last few days?
Pure coincidence, at least on my part :) I just thought that it'd be useful to modularize and release functions/objects that can be reused, both for myself and others.

More to come from me...

Joe Soap
Regular
Posts:475
Joined:07 Jul 2012 15:04

Re: Module for working with Vectors

Post by Joe Soap » 03 Dec 2012 21:21

Nice one man. :)


I'd go further with this idea in fact, as though very useful (and appreciated) . . . it still falls into the category of "the code is the documentation". All well and good for those from (almost any) coding background - but still quite a leap.

For instance it might be a nice idea to explain to people why vectors are useful / necessary. What sorts of things are they used for etc.Oftentimes, the level of abstraction involved makes it difficult to connect the dots between an idea someone has in mind to the underlying techniques required to implement that idea?

IOW . . . we need pics and diagrams, real-world examples, to stand alongside code examples / modules. Nothing about the process should be considered too basic to outline.

This isn't a criticism levelled at you specifically (or at all), Glad people are making the effort.

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: Module for working with Vectors

Post by brianc » 03 Dec 2012 21:27

I definitely agree with you. I chose to be pretty minimal on the documentation just to keep the code small. Most of my projects are pretty big and use quite a few modules like this, and I try to keep the code as small (but still readable) as I can.

Maybe I'll start creating a separate README instead of just the small README() functions included in my modules (those are limited by the cap on script size). I'm also planning to include example templates with modules to show a little bit about how to integrate the modules.

Phil999
Regular
Posts:932
Joined:11 Jan 2012 01:53

Re: Module for working with Vectors

Post by Phil999 » 03 Dec 2012 23:31

that would be very helpful.

Thank you very much for these modules. They are complex, therefore look interesting, but I don't know how to take advantage of or learn from them.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro

Joe Soap
Regular
Posts:475
Joined:07 Jul 2012 15:04

Re: Module for working with Vectors

Post by Joe Soap » 04 Dec 2012 00:00

@ Phil999 . . . exactly.

I mean, I have a very rough idea what vectors can be used for (indexing into grids?) . . . but even that (and I may be misunderstanding even still) bit of knowledge was hard-won, from the contexts in which "use vectors" seemed to be the answer (here on the forums).

Oh . . . I've seen various people handwave in the direction of "any basic programming tutorial" etc when asked to explain some stuff further - but this kind of advice rather misses the point. WHICH basic turorial??? Link some FFS!!! :P

It's a wild and wooly internet out there . . . what if some poor n00b* ends up studying Haskell or LISP in their ignorance? :D

* Yeah . . . I'll cop to that.

Macciza
Regular
Posts:1325
Joined:07 Dec 2011 04:57
Location:Sydney, Australia.

Re: Module for working with Vectors

Post by Macciza » 04 Dec 2012 07:49

Hi All

Nice bit of work there though I still have to have a good look through it all . . .
But a few general comments . . .

I must admit I think I prefer 'array' to 'vector' as terminology but much of a muchness in the end - both terms have simultaneous overlapping and exclusive definitions in my mind . .

Think of an 'array/vector' as a 'list' - a bunch of numbers or names that you can access by there position/index in the list . . .

In general I would say check out a 'C-based' tutorial just to get an understanding of assignment, variables, equations, functions etc
There are not really any tutorials that cover both basic program design/structure and Lemur specific approaches . . .

A few specific comments . .

Not sure what the usual result should be for adding unequal arrays - I thought you 0-padded the shorter and return the longer of the two . . .
This is actually the result you get when using standard maths operations on arrays in Lemur ie {1, 2, 3}+{4, 5, 6, 7} = {5,7,9,7}
Perhaps it would be better to call them add_tr, subtract_tr etc to make it clear that they truncate to the shortest as opposed to maintain longest length

Any particular reason why you went with functions for some and scripts for others - ie push vs pop?? Just wondering . . .
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]

brianc
Regular
Posts:87
Joined:10 Jan 2012 02:16

Re: Module for working with Vectors

Post by brianc » 04 Dec 2012 16:15

Macciza wrote:I must admit I think I prefer 'array' to 'vector' as terminology but much of a muchness in the end - both terms have simultaneous overlapping and exclusive definitions in my mind . .
I do too. I went with the word "vector" just because that's what the Lemur documentation calls them.
Macciza wrote:Not sure what the usual result should be for adding unequal arrays - I thought you 0-padded the shorter and return the longer of the two . . .
This is actually the result you get when using standard maths operations on arrays in Lemur ie {1, 2, 3}+{4, 5, 6, 7} = {5,7,9,7}
Perhaps it would be better to call them add_tr, subtract_tr etc to make it clear that they truncate to the shortest as opposed to maintain longest length
Yeah, this was a tough design decision. In the mathematical sense, vectors of different dimensions aren't compatible, and just about all implementations of element-by-element arithmetic I've seen (MATLAB/Octave, Mathematica, R, and implementations I've encountered in C/C++/Python) all assert that the lengths are the same. Because of that, I don't like the way it's done in Lemur. I suppose I should make the change, though, to at least make it consistent. Next version...
Macciza wrote:Any particular reason why you went with functions for some and scripts for others - ie push vs pop?? Just wondering . . .
Size. For things I could do as one-liners, I used functions.


Can you think of anything that's missing? The next version will also have filter functions, like ge({9,4,6,1,3,5,8},5) returns all elements greater than or equal to 5, or {9,6,5,8}.

lABl
Lemur Guru
Posts:269
Joined:09 Dec 2011 15:56
Contact:

Re: Module for working with Vectors

Post by lABl » 05 Dec 2012 12:19

Some good functions there Brianc, thanks! I think some of them mightbe built-in functions.

That is one thing I have requested from legacy times, I would love to save/load functions, instead of copy/pasting or re-writing from scratch, but hey, Liine guys are makig a great job with lemur imo, so simply I can't complaint.

@Macciza about of adding arrays with different sizes, recently I had a project where I used it alot (generative template), so I what did was to wrap arrays, I don't know if this helps in some way, but I have added a file.

Cheers and thanks again brianc.
Attachments
addArray.jzml
(1.72KiB)Downloaded 223 times

Post Reply