本人欲将libsvm用Bcb做成dll供delphi调用,其部分声明如下:
struct svm_node
{
int index;
double value;
};
struct svm_parameter
{
int svm_type;
int kernel_type;
...
};
struct svm_model
{
svm_parameter param; // parameter
int nr_class;
int l; // total #SV
svm_node **SV; // SVs (SV[l])
double **sv_coef; // coefficients for SVs in decision functions (sv_coef[n-1][l])
//上两句每句有两个*,该怎么翻译成Pascal才能在下面的函数中正确调用?SV好像是指针数组在svm_predict中初始化。
...
};
__declspec(dllexport) double _stdcall svm_predict(const struct svm_model *model, const struct svm_node *x);
不知哪位大虾,能帮忙翻译一下。
struct svm_node
{
int index;
double value;
};
struct svm_parameter
{
int svm_type;
int kernel_type;
...
};
struct svm_model
{
svm_parameter param; // parameter
int nr_class;
int l; // total #SV
svm_node **SV; // SVs (SV[l])
double **sv_coef; // coefficients for SVs in decision functions (sv_coef[n-1][l])
//上两句每句有两个*,该怎么翻译成Pascal才能在下面的函数中正确调用?SV好像是指针数组在svm_predict中初始化。
...
};
__declspec(dllexport) double _stdcall svm_predict(const struct svm_model *model, const struct svm_node *x);
不知哪位大虾,能帮忙翻译一下。
解决方案 »
- 请各位大虾告诉我!!!急急急~~~~~
- Borland公司能否通过分析EXE文件,来确定这个程序是不是盗版Delhpi软件编译的?
- 如何和控制台程序进行通讯呢?
- 想保存数据库里的数据,怎么生成insert的sql语句?
- VC++转化为Pascal?
- 请各位仁兄帮帮忙,关于打印预览的问题。
- 衷心恳请得到CSDN高手的帮助--关于mx方式发信。一定给分!一定结帐!
- delphi 指针搜索问题
- 调查:请问大家编码时是不是严格按照标准风格来写(比如大小写,缩进,变量命名等)?
- 老鱼大哥,分给了,我笨,嘻嘻,你原谅我,还有个问题,请进。。。
- 如何在DELPHI应用项目中的空闲事件中写脚本?在线等。。。
- 发现D2005的一个BUG
pdouble = ^double;
ppdouble = ^pdouble; // 二维指针type svm_node = record
index: Integer;
value: Double;
end;
psvm_node = ^svm_node;
ppsvm_node = ^psvm_node; // 二级指针type svm_parameter = record
svm_type: Integer;
kernel_type: Integer;
end;
psvm_parameter = ^svm_parameter;type svm_model = record
param: svm_parameter;
nr_class: Integer;
l: Integer;
SV: ppsvm_node;
sv_coef: ppdouble;
end;
Psvm_model = ^svm_model;function svm_predict(const model: psvm_model; const x:psvm_node):double;stdcall;externel '***.dll' name 'svm_predict';
model: svm_model;
x: svm_node; param: svm_parameter;
SV: ppsvm_node;
sv_coef: ppdouble; I: Integer;
tmp: ppdouble;
tmp2: ppsvm_node begin
param.svm_type := 0;
param.kernel_type := 0; model.param := param;
model.nr_class := 0;
model.l := 0;
GetMem(SV, 10 * 4); // 分配10长度为10 分配第一维
tmp2 := SV;
for I := 0 to 9 do
begin
GetMem(tmp2^, sizeof(svm_node)); // 为每一维 分配 20 注意 长度为 sizeof(svm_node)
Inc(tmp2);
end; GetMem(sv_coef, 10 * 4); // 分配10长度为10 分配第一维
ppdouble := sv_coef;
for I := 0 to 9 do // 为每一维 分配 20
begin
GetMem(ppdouble^, 20 * 4);
Inc(ppdouble);
end; //
// 所以 sv_coef 就是一个 二维double指针 相当于 double aaa[10][20] model.SV := SV;
model.sv_coef := sv_coef; x.index := 0;
x.value := 0;
// call like this
svm_predict(psvm_model(@model), psvm_node(@x));
end;// 有问题 请再说...