quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_numeric.a #include <Kernel.h> #include <Kernel.h> boolean setConstants(const VectorFloat& constants); boolean compute(float& value, const VectorFloat& x, const VectorFloat& y);
description:// define kernel constants // VectorFloat constants(L"1.4"); // define kernel // Kernel k; k.setAlgorithm(Kernel::RBF); k.setConstants(constants); // evaluate result = kernel(x, y) // VectorFloat x(L"1, 3, 5"); VectorFloat y(L"2, 4, 6"); float result; k.compute(result, x, y);
static const String CLASS_NAME = L"Kernel";
enum ALGORITHM { LINEAR = 0, POLYNOMIAL, RBF, SIGMOID, DEF_ALGORITHM = LINEAR };
static const NameMap ALGO_MAP;
static const String DEF_PARAM = L"";
static const String PARAM_ALGORITHM = L"algorithm";
static const String PARAM_CONSTANTS = L"constants";
static const VectorFloat DEF_LIN_CONSTANTS;
static const VectorFloat DEF_POLY_CONSTANTS;
static const VectorFloat DEF_RBF_CONSTANTS;
static const VectorFloat DEF_SIGM_CONSTANTS;
static const long ERR = 35700;
static const long ERR = 35701;
static const long ERR = 35702;
ALGORITHM algorithm_d;
VectorFloat constants_d;
boolean is_valid_d;
static MemoryManager mgr_d;
static Integral::DEBUG debug_level_d;required public methods:
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean setDebug(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~Kernel();
Kernel();
Kernel(const Kernel& arg);
boolean assign(const Kernel& arg)
Kernel& operator= (const Kernel& arg);
long sofSize() const;
boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);
boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM,long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
boolean eq(const Kernel& arg) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);
boolean setAlgorithm(ALGORITHM algorithm);
boolean setConstants(const VectorFloat& constants);
ALGORITHM getAlgorithm();
const VectorFloat& getConstants() const;
boolean compute(float& value, const VectorFloat& x, const VectorFloat& y);
boolean compute(double& value, const VectorDouble& x, const VectorDouble& y);
boolean init();
boolean computeLinear(float& value, const VectorFloat& x, const VectorFloat& y);
boolean computeLinear(double& value, const VectorDouble& x, const VectorDouble& y);
boolean computePolynomial(float& value, const VectorFloat& x, const VectorFloat& y);
boolean computePolynomial(double& value, const VectorDouble& x, const VectorDouble& y);
boolean computeRBF(float& value, const VectorFloat& x, const VectorFloat& y);
boolean computeRBF(double& value, const VectorDouble& x, const VectorDouble& y);
boolean computeSigmoid(float& value, const VectorFloat& x, const VectorFloat& y);
boolean computeSigmoid(double& value, const VectorDouble& x, const VectorDouble& y);
// isip include files // #include <Kernel.h> #include <Console.h> // main program starts here // int main (int argc, const char **argv) { // define two vectors // VectorFloat x(L"1.2, 0.3, 0.1"); VectorFloat y(L"0.2, 1.1, 0.8"); // define output string and resulting value // String out; float result; // define kernel and kernel constants // Kernel k; VectorFloat constants; // evaluate y = kernel(x, y) for LINEAR, POLYNOMIAL, RBF and SIGMOID kernels // k.setAlgorithm(Kernel::LINEAR); k.compute(result, x, y); out.assign(result); Console::put(out); k.setAlgorithm(Kernel::POLYNOMIAL); constants.assign(L"0.2"); k.setConstants(constants); k.compute(result, x, y); out.assign(result); Console::put(out); k.setAlgorithm(Kernel::RBF); constants.assign(L"0.5"); k.setConstants(constants); k.compute(result, x, y); out.assign(result); Console::put(out); k.setAlgorithm(Kernel::SIGMOID); constants.assign(L"0.2, 0.4"); k.setConstants(constants); k.compute(result, x, y); out.assign(result); Console::put(out); // exit gracefully // Integral::exit(); }