Example of how to use XLKit
#include <stdio.h>
xlCirc(double diameter)
{
return diameter * 3.14159;
}
xlStats(xlParmDataRange cells)
{
double sum = 0.0;
double sum_of_squares = 0.0;
for (int i = 0; i < src.rows(); ++i)
{
for (int j = 0; j < src.cols(); ++j)
{
double x = src(i, j).get<double>();
sum += x;
sum_of_squares += x*x;
}
}
int num_items = src.rows() * src.cols();
if (num_items == 0)
double average = sum / num_items;
mat(0, 0).set(average);
mat(0, 1).set(sum_of_squares / num_items - average * average);
return result;
}
XLKIT_REGISTER(xlStats,
"Compute mean and variance as 1x2 cell range")
xlMatrixRef(xlParmDataRange cells)
{
return result;
}