Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Parallelization of multiple nested loops

by QM (Parson)
on Feb 07, 2018 at 11:53 UTC ( [id://1208624]=note: print w/replies, xml ) Need Help??


in reply to Parallelization of multiple nested loops

You could also rework the nested loops into permutations or globs, and just have a single loop with an iterator.

I would naively suggest glob, but for your example, it eats up memory, and probably doesn't finish:

#!/usr/bin/env perl use strict; use warnings; # dummy values for @p, to get the last values not in a loop my @p = 0..12; # a single value # (this can be generalized, as parameters to a function to generate th +is string) my $glob_token = '{0.0,0.2,0.4,0.6,0.8,1.0}'; # join into multiple value string # (must use non-whitespace, as the builtin glob treats whitespace spec +ial) my $glob_parm = join(",", ($glob_token) x 11); # Loop fork for my $parm_list (glob($glob_parm)) { # now fix the commas $parm_list =~ s/,/\t/g; my $temp_out = "$parm_list\t$p[11]\t$p[12]\n"; print $temp_out; }

A similar solution using permutations a combination iterator would work. I'll have to see if I can find my array-of-arrays permutation iterator.

Update: This node on this thread should help.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found