New answers tagged

2

Here, I will use LibraryLink technique to calculate the nonzero B-spline basis. About the C code, please see happy fish's revision. Firstly, I make a comparison with optimizedNonzeroBasis[], compiledNonzeroBasis[] and librarylinkNonzeroBasis[]. knots0 = Join[ConstantArray[0, 3001], Range[1, 5000], ConstantArray[5001, 3001]]; deg0 = 3000; i = 3002; ...


6

Your question probably will not get the answer you are looking for, because although it is technically possible, getting Compile to work properly is hard enough already without the added difficulty of automatically preprocessing its input. Thus I think that this approach will tend to obscure and complicate the job, rather than making anything easier. The ...


7

First define the function normally: g[y_] := y^2; Then substitute the definition in: f = ReleaseHold[Hold[Compile[{{x, _Real}}, g[x], CompilationTarget -> "C"]] /. DownValues[g]] And there is no longer MainEvaluatein the compiled function. As Oleksandr R. suggested, you can also do g = #^2 &; f = Compile[{{x, _Real}}, g[x], ...


5

This will compile just fine, though as others have said, Compile is a tricky beast. One key thing to remember is adding 0.0 I to your initialization of M, otherwise you will get a Compile::cset error message. compiledrRefl = Compile[{{λ, _Real}, {d1, _Real}, {d2, _Real}, {n1, _Complex}, {n2, _Complex}, {Np, _Integer}}, ...



Top 50 recent answers are included