omp parallel for private(i,j,d,k,tmp)
513339
def pairwise(X):
    M = X.shape[0]
    N = X.shape[1]
    D = numpy.zeros((M,N))
    ""
    for i in xrange(M):
        for j in xrange(M):
            d = 0.0
            for k in xrange(N):
                tmp = X[i,k] - X[j,k]
                d += tmp * tmp
            D[i,j] = math.sqrt(d)
    return D
292947
def _map_parallel(function, args, n_jobs):
    """"""
    # Following the error checking found in joblib
    multiprocessing = int(os.environ.get('JOBLIB_MULTIPROCESSING', 1)) or None
    if multiprocessing:
        try:
            import multiprocessing
            import multiprocessing.pool
        except ImportError:
            multiprocessing = None
        if sys.platform.startswith("win") and PY2:
            msg = "Multiprocessing is not supported on Windows with Python 2.X. Setting n_jobs=1"
            logger.warning(msg)
            n_jobs = 1
    # 2nd stage: validate that locking is available on the system and
    #            issue a warning if not
    if multiprocessing:
        try:
            _sem = multiprocessing.Semaphore()
            del _sem  # cleanup
        except (ImportError, OSError) as e:
            multiprocessing = None
            logger.warning('{}. _map_parallel will operate in serial mode'.format(e))
    if multiprocessing and int(n_jobs) not in (0, 1):
        if n_jobs == -1:
            n_jobs = None
        try:
            pool = multiprocessing.Pool(processes=n_jobs)
            map_result = pool.map(function, args)
        finally:
            pool.close()
            pool.join()
    else:
        map_result = list(map(function, args))
    return map_result
714327
def icmp(a, b):
    ""
    for xa in a:
        try:
            xb = next(b)
            d = cmp(xa, xb)
            if d: return d
        except StopIteration:
            return 1
    try:
        next(b)
        return -1
    except StopIteration:
        return 0
545209
private static void eltran(DenseMatrix A, DenseMatrix V, int[] perm) {
        int n = A.nrows();
        for (int mp = n - 2; mp > 0; mp--) {
            for (int k = mp + 1; k < n; k++) {
                V.set(k, mp, A.get(k, mp - 1));
            }
            int i = perm[mp];
            if (i != mp) {
                for (int j = mp; j < n; j++) {
                    V.set(mp, j, V.get(i, j));
                    V.set(i, j, 0.0);
                }
                V.set(i, mp, 1.0);
            }
        }
    }
1040100
function parallel(tasks, params, last) {
    var onEnd = (typeof params === 'function') ? params : params.done || last,
        running = [],
        results = [],
        d = 0,
        t,
        l,
        i;

    if (typeof onEnd !== 'function')
      onEnd = noop;

    function cleanup() {
      running.forEach(function(r) {
        clearTimeout(r);
      });
    }

    function onTaskEnd(err, result) {
      // Adding results to accumulator
      results.push(result);

      if (err) {
        cleanup();
        return onEnd(err, results);
      }

      if (++d >= tasks.length) {

        // Parallel action is finished, returning
        return onEnd(null, results);
      }

      // Adding on stack
      t = tasks[i++];
      running.push(async(t, onTaskEnd));
    }

    for (i = 0, l = params.limit || tasks.length; i < l; i++) {
      t = tasks[i];

      // Dispatching the function asynchronously
      running.push(async(t, onTaskEnd));
    }
  }
459961
static void computePPXP( DMatrixRMaj P , DMatrixRMaj P_plus, DMatrixRMaj X , int offsetX,  DMatrixRMaj output ) {
		final int N = P.numRows;
		output.reshape(N,2);

		// diag(X) * P <-- N x 2
		for (int i = 0, index=0; i < N; i++, index += 2) {
			double x = -X.data[index+offsetX];
			output.data[index] = x*P.data[index];
			output.data[index+1] = x*P.data[index+1];
		}

		// A = P_plus*( diag(x)*P ) <-- 2 x 2
		double a00=0,a01=0,a10=0,a11=0;
		for (int i = 0, index=0; i < N; i++, index += 2) {
			a00 += P_plus.data[i]*output.data[index];
			a01 += P_plus.data[i]*output.data[index+1];
			a10 += P_plus.data[i+N]*output.data[index];
			a11 += P_plus.data[i+N]*output.data[index+1];
		}

		// P*A <-- N x 2
		for (int i = 0, index=0; i < N; i++, index += 2) {
			output.data[index]   = P.data[index]*a00 + P.data[index+1]*a10;
			output.data[index+1] = P.data[index]*a01+ P.data[index+1]*a11;
		}
	}
92186
def parallel_fn(f):
    

    def simple_parallel(func, sequence, **args):
        """ f takes an element of sequence as input and the keyword args in **args"""
        if 'processes' in args:
            processes = args.get('processes')
            del args['processes']
        else:
            processes = multiprocessing.cpu_count()

        pool = multiprocessing.Pool(processes)  # depends on available cores

        result = pool.map_async(universal_worker, pool_args(func, sequence, args))
        pool.close()
        pool.join()
        cleaned = [x for x in result.get() if x is not None]  # getting results
        cleaned = asarray(cleaned)
        return cleaned
    return partial(simple_parallel, f)
738950
static void computePseudo(DMatrixRMaj A , DMatrixRMaj output ) {
		final int N = A.numRows;

		DMatrix2x2 m = new DMatrix2x2();
		DMatrix2x2 m_inv = new DMatrix2x2();

		for (int i = 0, index=0; i < N; i++) {
			double a_i1 = A.data[index++];
			double a_i2 = A.data[index++];
			m.a11 += a_i1*a_i1;
			m.a12 += a_i1*a_i2;
			m.a22 += a_i2*a_i2;
		}
		m.a21 = m.a12;
		CommonOps_DDF2.invert(m,m_inv);

		output.reshape(2,N);
		for (int i = 0,index=0; i < N; i++) {
			output.data[i] = A.data[index++]*m_inv.a11 + A.data[index++]*m_inv.a12;
		}
		int end = 2*N;
		for (int i = N,A_index=0; i < end; i++) {
			output.data[i] = A.data[A_index++]*m_inv.a21 + A.data[A_index++]*m_inv.a22;
		}
	}
263916
private void trace(char mod, int i, int j)
	{
		if(mod == '0' || i <= 0 || j <= 0)      {
			B1 = i + 1;
			B2 = j + 1;
		}
		if(mod == 's')  {
			trace(trace[i - 1][j - 1], i - 1, j - 1);
			rep();
		}
		else if(mod == 'D')     {
			trace(trace[i - 1][j], i - 1, j);
			del(1);
		}
		else if(mod == 'd')     {
			trace(dtrace[i - 1][j], i - 1, j);
			del(1);
		}
		else if(mod == 'E')     {
			trace(trace[i][j - 1], i, j - 1);
			ins(1);
		}
		else if(mod == 'e')     {
			trace(etrace[i][j - 1], i, j - 1);
			ins(1);
		}
	}
791258
def runInParallel(*fns):
        
        proc = []
        for fn in fns:
            p = Process(target=fn)
            p.start()
            proc.append(p)
        for p in proc:
            p.join()
426292
def memberwise(op, x)
      case x
      when Benchmark::Tms
        Benchmark::Tms.new(utime.__send__(op, x.utime),
                           stime.__send__(op, x.stime),
                           cutime.__send__(op, x.cutime),
                           cstime.__send__(op, x.cstime),
                           real.__send__(op, x.real)
                           )
      else
        Benchmark::Tms.new(utime.__send__(op, x),
                           stime.__send__(op, x),
                           cutime.__send__(op, x),
                           cstime.__send__(op, x),
                           real.__send__(op, x)
                           )
      end
    end
54223
def _multi_lpop_pipeline(self, pipe, queue, number):
        ''' '''
        pipe.lrange(queue, 0, number - 1)
        pipe.ltrim(queue, number, -1)
669136
private List<Double> getTopN(INDArray vec, int N) {
        BasicModelUtils.ArrayComparator comparator = new BasicModelUtils.ArrayComparator();
        PriorityQueue<Double[]> queue = new PriorityQueue<>(vec.rows(), comparator);

        for (int j = 0; j < vec.length(); j++) {
            final Double[] pair = new Double[] {vec.getDouble(j), (double) j};
            if (queue.size() < N) {
                queue.add(pair);
            } else {
                Double[] head = queue.peek();
                if (comparator.compare(pair, head) > 0) {
                    queue.poll();
                    queue.add(pair);
                }
            }
        }

        List<Double> lowToHighSimLst = new ArrayList<>();

        while (!queue.isEmpty()) {
            double ind = queue.poll()[1];
            lowToHighSimLst.add(ind);
        }
        return Lists.reverse(lowToHighSimLst);
    }
1099573
def dp_from_ps(bk, pk, ps, pfull_coord):
    """"""
    return d_deta_from_phalf(phalf_from_ps(bk, pk, ps), pfull_coord)
22129
def _free_sequence(tmp1, tmp2=False):
    ''' 
    '''
    if not tmp1 and not tmp2:
        return []

    output = []
    if tmp1 and tmp2:
        output.append('pop de')
        output.append('ex (sp), hl')
        output.append('push de')
        output.append('call __MEM_FREE')
        output.append('pop hl')
        output.append('call __MEM_FREE')
    else:
        output.append('ex (sp), hl')
        output.append('call __MEM_FREE')

    output.append('pop hl')
    REQUIRES.add('alloc.asm')
    return output
299741
private List<List<K>> prepareKeysForParallelism() {
		// Calculate the number of row keys to be queried at a time.
		// Consider whether parallelism is enabled or not.
		// When numThreads is calculated, the int truncation
		// causes one fewer thread to be used if numKeys isn't evenly divided
		// into maxRowCountPerQuery. Thus,
		// the keys are divided among threads/ calls evenly with each thread
		// getting up to maxRowCountPerQuery

		List<List<K>> returnKeys = new LinkedList<List<K>>();

		int numKeys = rowKeys.size();

		// Calculate how many thread are required based on input # keys and each
		// time rowkeys limit of maxRowCountPerQuery
		int numThreads = 1;

		if(maxRowCountPerQuery>0){
			numThreads=(int) Math.ceil((numKeys / (double) maxRowCountPerQuery));
			numThreads=	Math.max(numThreads, 1);
		}

		// if number of threads required is more than the maximum limit of
		// allowable threads then cap the number of threads

		threadCount=Math.min(numThreads, maxThreads);
		
		// We get the ceiling of numKeys/numThreads in order to spread out the
		// row keys evenly.
		// e.g. if numKeys=101 and maxRowCountPerQuery=50, it makes set of 34
		// keys to be queried at a time. numThreads= Ceil(101/50)=>3

		numKeysPerThread = (int) Math
				.ceil(numKeys / (double) numThreads);

		 // Default it to 1, so that all keys will be passed once, instead of breaking it
		numKeysPerThread=Math.max(numKeysPerThread, 1);
		
		//Check if there are any rowkeys 
		if(this.rowKeys!=null && this.rowKeys.size()>0)		{
			// split keys into subsets based on the above calculation
			returnKeys = Lists.partition(rowKeys, numKeysPerThread);
		}

		return returnKeys;

	}
242171
public static <K, V> void forEachKeyValue(
            Map<K, V> map,
            Procedure2<? super K, ? super V> procedure,
            int minForkSize,
            int taskCount)
    {
        if (map.size() > minForkSize)
        {
            Procedure<Pair<K, V>> pairProcedure = new PairProcedure<K, V>(procedure);
            ParallelIterate.forEach(MapIterate.toListOfPairs(map), new PassThruProcedureFactory<Procedure<Pair<K, V>>>(pairProcedure), new PassThruCombiner<Procedure<Pair<K, V>>>(), minForkSize, taskCount);
        }
        else
        {
            MapIterate.forEachKeyValue(map, procedure);
        }
    }