C++时间库和八度.oct文件
C++ Time Library and Octave .oct files
我正在尝试编写一个使用 linasm-1.13 库的 Octave C++ .oct 函数,但我似乎甚至无法从/usr/share/zoneinfo/获得 tzdata 的基本加载来工作。到目前为止,我的简单测试函数是
#include <octave/oct.h>
#include <Time.h> // the linasm-1.13 library
DEFUN_DLD ( tz, args, nargout,
"-*- texinfo -*-n
@deftypefn {Function File} {} tz (@var{YYYYMMDDHHMMSS})n
n
@end deftypefn" )
{
octave_value_list retval_list ;
unsigned int tz ;
const char *ny_time = "/usr/share/zoneinfo/America/New_York" ;
tz = Time::LoadTimeZone( ny_time ) ;
return retval_list ;
在使用 mkoctfile 编译时,会给出此错误
>> mkoctfile tz.cc
tz.cc: In function ‘octave_value_list Ftz(const octave_value_list&, int)’:
tz.cc:24:34: error: cannot call member function ‘unsigned int Time::LoadTimeZone(const char*)’ without object
tz = Time::LoadTimeZone( ny_time ) ;
^
warning: mkoctfile: building exited with failure status
我对此的理解是,ny_time不是一个被识别的对象,但我尝试ny_time转换为字符串文字,如这个公认的 SO 答案中所述。
我这样做是因为根据linasm页面,LoadTimeZone的输入应该是"tzfile的路径,它描述了所需的时区"。我哪里出错了?
我认为您还必须#include "source.cc"
文件,而不仅仅是#include "header.h"
文件。在你的情况下,我想你应该补充:#include "Time.cc"
或类似的东西。我不知道为什么,但是在使用 Rafat 的 Hussain wavemin 库时,这对我有用,但我只有 4 个文件,有很多文件一定非常乏味。
这就是我所做的(这是 Rafat 和他的库提供的测试代码的修改版本)。
#include "wavemin.h"
#include "waveaux.h"
#include "wavemin.cc"
#include "waveaux.cc"
#include <octave/oct.h>
double ensayo();
double absmax(double *array, int N);
DEFUN_DLD(helloctave2, argv, , "Usage: hello()"){
wave_object obj;
wt_object wt;
double *inp, *out, *diff;
int N, i, J;
char *name = "db4";
obj = wave_init(name);// Initialize the wavelet
N = 14; //Length of Signal
inp = (double*)malloc(sizeof(double)* N); //Input signal
out = (double*)malloc(sizeof(double)* N);
diff = (double*)malloc(sizeof(double)* N);
//wmean = mean(temp, N);
for (i = 0; i < N; ++i) {
inp[i] = i;
}
J = 1; //Decomposition Levels
wt = wt_init(obj, "dwt", N, J);// Initialize the wavelet transform object
setDWTExtension(wt, "sym");// Options are "per" and "sym". Symmetric is the default option
setWTConv(wt, "direct");
dwt(wt, inp);// Perform DWT
//DWT output can be accessed using wt->output vector. Use wt_summary to find out how to extract appx and detail coefficients
for (i = 0; i < wt->outlength; ++i) {
octave_stdout << wt->output[i];
octave_stdout << "n";
}
idwt(wt, out);// Perform IDWT (if needed)
// Test Reconstruction
for (i = 0; i < wt->siglength; ++i) {
diff[i] = out[i] - inp[i];
}
octave_stdout << absmax(diff, wt->siglength);
octave_stdout << "n";
octave_value_list retval;
return retval;
}
double
absmax(double *array, int N) {
double max;
int i;
max = 0.0;
for (i = 0; i < N; ++i) {
if (fabs(array[i]) >= max) {
max = fabs(array[i]);
}
}
return max;
}
相关文章:
- 编写一个程序,帮助Tudio将MIDI音符转换为名称和八度音阶
- 运行简单的.oct文件时Octave崩溃,我的代码出了什么问题?
- 将八度Griddata功能移植到iOS
- C++时间库和八度.oct文件
- 十六进制、二进制和 oct 到 dec 转换器无法正常工作C++
- MEX文件构建具有八度的构建(包装纸问题)
- 使用 mkoctfile 与 Octave 和 Visual Studio 2010 编译器编译 .mex 或 .oct
- oct文件中NDArray的乘法运算
- 在 C 中使用八度内置函数
- DTW算法OCT文件
- 如何迭代Quad/Oct树
- 八度有趣的错误 - 无法定义函数
- 如何在给定的 MIDI 音符/八度音阶下播放声音
- 写入 .oct 文件中的矩阵而不循环
- 在 Ubuntu 上使用 Mingw64 交叉编译 Matlab oct 文件时出现问题
- 为什么 int -> 十六进制/oct/bin 的转换在输出中打印为纯十进制值?
- 在嵌入式八度C++中如何执行脚本文件?( "error: invalid call to script" )
- C++ While Loop: Hex & Oct, & Dec
- 在c++中读取一个八度二进制文件
- 八度值维度