Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Generate Array?

For general discussion related FlowStone

Generate Array?

Postby guyman » Sat Nov 16, 2019 11:11 pm

Ok last question for the day.
What's the best way to generate/calculate an array from scratch, in consistent relation to a function from last entry, or the index # ?
so just..
Designating # of x bins...
entering function (ie x=x+3... or x=index ..or x=index*2+3/4^179)

I'm going for pretty big arrays.....
User avatar
guyman
 
Posts: 207
Joined: Fri Mar 02, 2018 8:27 pm

Re: Generate Array?

Postby RJHollins » Sun Nov 17, 2019 12:33 am

Hi Guy ...

not sure exactly what your looking for ... but posted sometime back, TROG had put together a package of modules called 'TROGS TOOLZ'.

In the 'Auto Numbering folder is an AutoFunction Generator that can generate a variety of Arrays and functions.

not sure if this the latest ... but maybe can help:
Attachments
trogz_toolz_v3_1.fsm
(226.42 KiB) Downloaded 800 times
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: Generate Array?

Postby tulamide » Sun Nov 17, 2019 1:14 am

guyman wrote:What's the best way to generate/calculate an array from scratch, in consistent relation to a function from last entry, or the index # ?

If you know the size of the array beforehand, the best way is to use its built in method #new:

Code: Select all
my_array = Array.new(20) { |index| index*2+3/4^179 }
## creates an array with 20 entries calculated from the code block {}


if you don't know the size beforehand you have to append to an existing array, for example:

Code: Select all
my_array = []
index = 0
my_array << index*2+3/4^179


This will make you happy: https://ruby-doc.org/core-1.9.3/index.html
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Generate Array?

Postby martinvicanek » Sun Nov 17, 2019 3:55 pm

Some options for array creation are: :mrgreen:
Attachments
buildArray3.png
buildArray3.png (16.95 KiB) Viewed 10428 times
buildArray2.png
This one will probably upset tula ...
buildArray2.png (10.82 KiB) Viewed 10428 times
buildArray1.png
buildArray1.png (16.6 KiB) Viewed 10428 times
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Generate Array?

Postby tulamide » Sun Nov 17, 2019 4:35 pm

martinvicanek wrote:...
It does, Martin, it does. But for a good reason. It's not "the best" way as asked, it's the worst way, because it's not the Ruby way. A for loop is one of the worst methods, especially when doing large arrays, as the op said.

But the other methods impress me! I would never had thought about using ASM, that's amazing!
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Generate Array?

Postby wlangfor@uoguelph.ca » Fri Nov 22, 2019 7:58 pm

i like to build an array, as long as you're sure the index number is accurate there really is no drawback unlike javascript or php.
My youtube channel: DSPplug
My Websites: www.dspplug.com KVRaudio flowstone products
User avatar
wlangfor@uoguelph.ca
 
Posts: 912
Joined: Tue Apr 03, 2018 5:50 pm
Location: North Bay, Ontario, Canada


Return to General

Who is online

Users browsing this forum: Google [Bot] and 71 guests