Solved it! (or at least found a method that works).
Ref:
http://msdn.microsoft.com/en-us/library/yz2be5wk(VS.80).aspx (boxing and unboxing):
Code:
int i = 123;
object o = (object)i; // boxing
Code:
o = 123;
i = (int)o; // unboxing
So my code is now:
Code:
public static void int_function_1_func(double x, double xminusa, double bminusx, ref double res, object obj)
{
double[] sectdims = (double[])obj;
double r = sectdims[0];
double dna = sectdims[1];
double fcu = sectdims[2];
res = fcu * (1 - Math.Pow((1 - x / dna), 2)) * 2 * Math.Sqrt(r * r - Math.Pow(r - dna + x, 2));
}
public double integrate(double[] parama)
{
double dna = parama[1];
Object obj = (object)parama ;
double a = 0;
alglib.autogkstate s;
double v;
alglib.autogkreport rep;
alglib.autogksmooth(a, dna, out s);
alglib.autogkintegrate(s, int_function_1_func, obj);
alglib.autogkresults(s, out v, out rep);
return v ;
}
Which works!
My question now is, is this the best way, bearing in mind this comment from MS:
"In relation to simple assignments, boxing and unboxing are computationally expensive processes. When a value type is boxed, an entirely new object must be allocated and constructed. To a lesser degree, the cast required for unboxing is also expensive computationally. For more information, see Performance."?