Page 1 of 1
logarithms in ruby - working?
Posted: Tue May 20, 2014 8:59 am
by tester
Something like this.
Does it requires something else?
Re: logarithms in ruby - working?
Posted: Tue May 20, 2014 12:25 pm
by CoreStylerz
use Math.log(num,base)

- Cattura.PNG (9.1 KiB) Viewed 16417 times
http://www.ruby-doc.org/core-1.9.3/Math.html
Re: logarithms in ruby - working?
Posted: Tue May 20, 2014 6:24 pm
by tester
Nope, not with array that way.
Re: logarithms in ruby - working?
Posted: Tue May 20, 2014 9:11 pm
by Nubeat7
you need to do it with each array element, using 'each' in a oneliner like this:
Code: Select all
output 0,@arr.each_index{|i|@arr[i]=Math.log(@arr[i],2)}
Re: logarithms in ruby - working?
Posted: Tue May 20, 2014 10:53 pm
by tester
Okay, thanks on that.
Re: logarithms in ruby - working?
Posted: Tue May 20, 2014 11:16 pm
by RJHollins
Good stuff NuBeat !!
Thanks for helping us all

Re: logarithms in ruby - working?
Posted: Tue May 20, 2014 11:53 pm
by tester
There is one problem.
At each restart I get an error (see attached pic) and must retrig the module.
Re: logarithms in ruby - working?
Posted: Wed May 21, 2014 12:18 am
by Nubeat7
hmm looks like it does the operation on loading, also when you click insideand change space or something it recalculates the array which contains the already processed values, like this the values are getting smaller till they are aout of range (minus)
just put it in an event methode, to only get triggered from input, i think this should solve the problem ( it does here )
Re: logarithms in ruby - working?
Posted: Wed May 21, 2014 12:38 am
by tester
I added afterload/dupkicate triggers for input, works too (no error display in schematic).