I'm trying to set up an integration of spectral emission over a sphere. The problem is that the integral has to be done over longitude and latitude "theta" and "phi", but I need a spectrum to come out as a function of wavelength, "lambda". Wavelength is NOT a variable of integration -- rather, an array of wavelengths goes in and an array of fluxes as a function of wavelength comes out.
Right now I have this implemented as a for loop over wavelength inside which are the two nested "qpint1d" function calls. The first "qpint1d" function also has a for loop in it over "theta" to make the inner "qpint1d" call work with "theta" as a scalar. It works but as you can imagine, with nested for loops this is not very efficient.
I've tried to pass the wavelength through to the inner integral as a vector within the "private" structure so that instead of a vector over "phi", the inner function would return a matrix of "phi" vs. wavelength, thus eliminating the outermost for loop (over wavelength). No luck, though -- I'm just getting the error message from QPINT1D_QKEVAL about how the integrand function must return a vector of values. Is there a better way to do this?