I have the following code (showing an insignificant simplification) that I really need to run many times for different ps (its length can be 10^7 or so) and wSize. Is there a way to speed this up using the fact that I have a special function inside MovingMap?
ps = RandomReal[{-1, 1}, 100000];
wSize = 100;
Σinv = Inverse@ToeplitzMatrix@CovarianceFunction[ps, {wSize - 1}];
MovingMap[#.Σinv.# &, ps, wSize - 1, "Periodic"];
tmp = Partition[ps, wSize, 1, -1]; MapThread[Dot, {tmp, tmp.Transpose[Σinv]}]? – J. M.'s missing motivation Mar 20 '18 at 02:36movingDot = Compile[{{ps, _Real, 1}, {wSize, _Integer}}, With[{half[CapitalSigma]inv = Inverse@ToeplitzMatrix@CovarianceFunction[ps, {wSize - 1}]/2, halfWSize = wSize/2}, MovingMap[#.half[CapitalSigma]inv.# &, ps, wSize - 1, "Periodic"]] ] movingDot[ps, wSize];
CompiledFunction::cfse: Compiled expression {{2.9988,0.000143913,...,0.0015581,0.000759095,-0.000135168,<<37>>,-0.000601042,0.000877005,0.00026945,-0.000867925,0.00158341,0.000579952,<<50>>},{<<1>>},<<48>>,<<50>>} should be a machine-size real number.
– freevillage Mar 20 '18 at 16:54Inverse[]andCovarianceFunction[]withinCompile[], which you now know to be pointless. – J. M.'s missing motivation Mar 21 '18 at 18:09