views:

109

answers:

1

I'm looking to do some testing of loan calculations on the Mac. I know what an amortization schedule is, and yes, I know how to convert an algorithm into code, but I'm don't want to worry about screwing up the rounding, or reinventing the wheel.

Are there any Open Source C or Objective-C libraries that handle such calculations? I know about QuantLib, but it's in C++.

+1  A: 

I'm not aware of any, but I do know how to expose a C++ library to C code.

You could take that tack, and write a C portability layer for QuantLib (which seems pretty cool btw)... Start small, and expose 1 part of QuantLib at a time...

You'll need to use the C++ compiler yourself for your portability layer... For every class in QuantLib, you could do something like this:

struct Foo
{
    QuantsFooObject obj;
};

struct Foo* FooCreate();
void FooDestroy( struct Foo* foo );

void DoSomething( struct Foo* foo );

Essentially, you create a struct for every class in QuantLib that contains an instance of that class. You'll also create a pair of functions, 1 for creating your struct and 1 for deleting it... Finally, you'll create a function for every member function of the Quants object your wrapping...

Much of this you'll need to wrap in extern "C", to turn off the C++ name mangler (so you'll be able to use this library from C)... But in the end, you'll have something you can use from objective C...

dicroce