Re: [julia-users] Number of loops not known at compile time

2015-09-28 Thread Tim Holy
If I were doing this, I'd make u a Vector of NTuples, pass it in as an argument, and use N in @generating the body of the function. You can use Cartesian macros in the body of a generated function (many examples in base). --Tim On Monday, September 28, 2015 11:33:46 AM Giuseppe Ragusa wrote: >

Re: [julia-users] Number of loops not known at compile time

2015-09-28 Thread Erik Schnetter
Guiseppe In addition to using recursion, you can also use a macro to generate the code. However, this functionality is available in the "Cartesian" module which is part of Base Julia. You are probably looking for "@nloops". -erik On Mon, Sep 28, 2015 at 11:24 AM, Giuseppe Ragusa

Re: [julia-users] Number of loops not known at compile time

2015-09-28 Thread Giuseppe Ragusa
@erik thank you. I know of Base.Cartesian, but I was not able to make it work for my use case. @steven yes, that is what i was afraid of (I was trying to shy away from recursion). On Monday, September 28, 2015 at 8:23:48 PM UTC+2, Erik Schnetter wrote: > > Guiseppe > > In addition to using

Re: [julia-users] Number of loops not known at compile time

2015-09-28 Thread jonathan . bieler
If I understand correctly, the trick is to encode the dimension into the type of the arguments (using parametric types), then the @generated macro allows you to "write" a function just when the type of the arguments is known, so you can create the right numbers of loops on the fly.

[julia-users] Number of loops not known at compile time

2015-09-28 Thread Giuseppe Ragusa
I am having problems (serious problems!) to deal with algorithms that boil down do nested for loops but whose number of loops is not known at compile time. As an example consider this: ``` function tmp() r = 3 n = 100 λ = zeros(r) u = rand(n, r) counter = 0 Y =