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

it is about time...

For general discussion related FlowStone

Re: it is about time...

Postby KG_is_back » Tue Jan 24, 2017 3:36 am

110 wrote:right, there were more errors like that, they just didnt show up as errors as inputs were missing and stuff.


so now here...

Code: Select all
output (Math.log(@f1))

def Math.log(*p)
log(*p)
end

output (log(@f1))


nice try, 110, but "stack level too deep". hmpf.

you have it the other way around.
Code: Select all
def log(*p) #the definition of your new function
Math.log(*p) #the execution code
end

in C it would look like this, just to see what we're doing:
float log(*args)
{
return Math.log(*args);
}



110 wrote:interesting! :)

so i know two working methods now to choose from.

here is the next issue. for noise with chi distribution i need to trigger this

((Math.sqrt(-2.0*Math.log(1.0-(rand))))*(Math.cos((rand)*6.283185307))**2.0)

for n times and accumulate the result.

no idea how to do that in ruby - and no idea how to make 5 consecutive triggers from 1 outside the ruby object.

both would be a good exercise.


https://www.tutorialspoint.com/ruby/ruby_loops.htm

also there is a very useful way to do it using ".each" method on objects that can be iterated (Array, Range, etc.)
Here are several examples:

Code: Select all

#using Range object. passing .each method executed the code in {} brackets once for each integer in the range
(0...100).each{
|i| #this line is optional - it puts current value into variable i
#your code
}

#same as the one before, but it return array containing all the results.
(0...100).map{
|i|
#your code
}

#or alternatively, this does the same as above.
Array.new(100){
|i| #index within the array
#your code
}


KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 4:12 am

KG_is_back wrote:you have it the other way around.


thanks! not yet sure if i should do this to all functions in question, but it is good to learn anway.

will try the iterations stuff later.

another day i go for variables and my beloved comparisons and then i should have most things i need for a start.
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 4:52 am

chiiiiise...
Attachments
chi.fsm
(760 Bytes) Downloaded 873 times
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby RJHollins » Tue Jan 24, 2017 5:19 am

once again ... a BIG THANKS to You Guys for posting this evolution, and sharing.

More than just the 'CODE' ... I feel it so important to read, and get a sense of the 'thinking' that
Programmers exhibit. [if that makes sense ... it does do me]. Now to try and understand/learn.

Thanks
8-)
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 8:23 pm

so i´ve ben readin up on comparisons for an hour but i dont get it.

is there no simple method to compare two values and have it return a value?

i am writing small expressions using conditoinal statements like 300 * (a>0) + 500 * (a<=0) all the time, it is far more straight forward than splitting it up into 4 processes and use some kind of if type of statement... but 300 really wants to be multiplicated with 0 and 1 and doesnt really want to connect with "true".
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 8:33 pm

found this.

Code: Select all
output (@f1 == 7.0 ? 1.0 : 0.0) * 5


how can i shorten it further?
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 8:47 pm

hm okay comparison?1:0
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 9:52 pm

logic gates with up to 8 inputs
Attachments
110-8gates.fsm
(679 Bytes) Downloaded 937 times
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby 110 » Tue Jan 24, 2017 10:18 pm

is there a console or console object in flowstone where i can see what data came through and, if possible, of what type it was?
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Postby 110 » Wed Jan 25, 2017 12:51 am

this time hopefully without bugs
Attachments
110-8gates.fsm
(668 Bytes) Downloaded 859 times
110
 
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 68 guests