All of the implementation is C only, it makes no sense to wrap doubles in NSNumber.
#import <Cocoa/Cocoa.h>
@interface GRE:NSObject
@end
@implementation GRE
+ (NSNumber *) compute:(double) age :(double) iop :(double) cct :(double) vcd :(double) psd
{
double meanage = 5.64301, betaage = 0.23260;
double meaniop = 24.1386, betaiop = 0.09025;
double meancct = -14.3349, betacct = 0.71503;
double meanpsd = 9.76001, betapsd = 0.12376;
double meanvcd = 3.60828, betavcd = 0.17689;
double S0_t = 0.91831;
double t_cct = -1.0 * (cct/40.0);
double t_psd = psd / .2;
double t_vcd = vcd / 0.1;
double agedecade = age / 10.0;
double xbetamean = (agedecade - meanage) * betaage +
(iop - meaniop) * betaiop +
(t_cct - meancct) * betacct +
(t_psd - meanpsd) * betapsd +
(t_vcd - meanvcd) * betavcd;
double risk = 1 - pow(S0_t, exp(xbetamean));
return [NSNumber numberWithDouble:risk];
}
@end
int main()
{
NSAutoreleasePool * p = [NSAutoreleasePool new];
NSLog(@"Risk: %@", [GRE compute:(55) :(24) :(540): (.40) : (2.2)]);
[p release];
}