Ошибка "undeclared '_finite'" при компиляции панели инструментов SPAMS для MATLAB на Win10 - PullRequest
0 голосов
/ 02 января 2019

Я пытаюсь импортировать набор инструментов SPAMS для разреженных представлений в MATLAB, используя SPAMS v2.6 (скачано с http://spams -devel.gforge.inria.fr / downloads.html ), MATLAB R2018aи под Win10.Я уже скомпилировал MEX-файлы с MinGW64.

Ошибки возникают, когда я запускаю compile.m, кажется, что некоторые функции / модули (я не уверен, как их вызвать) могут быть скомпилированы, а другиене могу.Я попытался прокомментировать эти функции, вызвавшие ошибки (около половины всех функций), остальные работали хорошо, но они не могут пройти тесты в SPAMS.Я думаю, что эти функции были как-то интерактивными.

>> compile
Warning: Directory already exists. 
> In compile (line 150) 
compilation of: -I./linalg/ -I./prox/ prox/mex/mexSvmMisoOneVsRest.cpp
Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
compilation of: -I./linalg/ -I./decomp/ decomp/mex/mexProjSplx.cpp
Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexArchetypalAnalysis.cpp
Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexTrainDL.cpp
Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexStructTrainDL.cpp
Building with 'MinGW64 Compiler (C++)'.
Error using mex
In file included from .\prox/fista.h:24:0,
                 from .\dictLearn/dicts.h:36,
                 from E:\xm\data\SPAMS\spams-matlab-v2.6-2017-02-27\spams-matlab-v2.6\dictLearn\mex\mexStructTrainDL.cpp:37:
.\prox/project.h: In instantiation of 'void GraphPath<T, Int>::init_graph(const GraphPathStruct<T>&) [with T = double; Int = long long int]':
.\prox/fista.h:2195:17:   required from 'FISTA::GraphPathL0<T>::GraphPathL0(const FISTA::ParamReg<T>&) [with T = double]'
.\prox/fista.h:3399:39:   required from 'FISTA::Regularizer<T>* FISTA::setRegularizerVectors(const FISTA::ParamFISTA<T>&, const GraphStruct<T>*, const
TreeStruct<T>*, const GraphPathStruct<T>*) [with T = double]'
.\dictLearn/dicts.h:934:51:   required from 'void Trainer<T>::train_fista(const Data<T>&, const ParamDictLearn<T>&, const GraphStruct<T>*, const
TreeStruct<T>*) [with T = double]'
E:\xm\data\SPAMS\spams-matlab-v2.6-2017-02-27\spams-matlab-v2.6\dictLearn\mex\mexStructTrainDL.cpp:268:7:   required from 'void callFunction(mxArray**,
const mxArray**, int, int) [with T = double; mxArray = mxArray_tag]'
E:\xm\data\SPAMS\spams-matlab-v2.6-2017-02-27\spams-matlab-v2.6\dictLearn\mex\mexStructTrainDL.cpp:311:50:   required from here
.\prox/project.h:3157:25: error: '_finite' was not declared in this scope
       num_arcs[i]= isinf(graph.start_weights[i]) ? 2 :  3;

.\prox/project.h:3160:28: error: '_finite' was not declared in this scope
       num_arcs[i+_n]= isinf(graph.stop_weights[i]) ? 2 :  3;

.\prox/project.h:3191:17: error: '_finite' was not declared in this scope
       if (!isinf(graph.start_weights[i])) {

.\prox/project.h:3199:17: error: '_finite' was not declared in this scope
       if (!isinf(graph.stop_weights[i])) {

.\prox/project.h: In instantiation of 'void GraphPath<T, Int>::init_graph(const GraphPathStruct<T>&) [with T = float; Int = long long int]':
.\prox/fista.h:2195:17:   required from 'FISTA::GraphPathL0<T>::GraphPathL0(const FISTA::ParamReg<T>&) [with T = float]'
.\prox/fista.h:3399:39:   required from 'FISTA::Regularizer<T>* FISTA::setRegularizerVectors(const FISTA::ParamFISTA<T>&, const GraphStruct<T>*, const
TreeStruct<T>*, const GraphPathStruct<T>*) [with T = float]'
.\dictLearn/dicts.h:934:51:   required from 'void Trainer<T>::train_fista(const Data<T>&, const ParamDictLearn<T>&, const GraphStruct<T>*, const
TreeStruct<T>*) [with T = float]'
E:\xm\data\SPAMS\spams-matlab-v2.6-2017-02-27\spams-matlab-v2.6\dictLearn\mex\mexStructTrainDL.cpp:268:7:   required from 'void callFunction(mxArray**,
const mxArray**, int, int) [with T = float; mxArray = mxArray_tag]'
E:\xm\data\SPAMS\spams-matlab-v2.6-2017-02-27\spams-matlab-v2.6\dictLearn\mex\mexStructTrainDL.cpp:313:49:   required from here
.\prox/project.h:3157:25: error: '_finite' was not declared in this scope
       num_arcs[i]= isinf(graph.start_weights[i]) ? 2 :  3;

.\prox/project.h:3160:28: error: '_finite' was not declared in this scope
       num_arcs[i+_n]= isinf(graph.stop_weights[i]) ? 2 :  3;

.\prox/project.h:3191:17: error: '_finite' was not declared in this scope
       if (!isinf(graph.start_weights[i])) {

.\prox/project.h:3199:17: error: '_finite' was not declared in this scope
       if (!isinf(graph.stop_weights[i])) {



Error in compile (line 447)
    mex(args{:});

1 Ответ

0 голосов
/ 02 января 2019

В файле linalg/misc.h, который поставляется со спамом, в верхней части файла имеется следующий бит кода:

#if defined(_MSC_VER) || defined(_WIN32) || defined(WINDOWS)
#define isnan _isnan
#define isinf !_finite
#endif

Это неправильно. _isnan и _finite относятся к компилятору Microsoft. Вы компилируете под Windows (и, таким образом, определены _WIN32 и WINDOWS), но не используете компилятор Microsoft, и поэтому эти ключевые слова не существуют.

Комментирование этого блока должно позволить вам скомпилировать набор инструментов SPAMS с помощью компилятора MinGW. (Или, по крайней мере, это предотвратит ошибку, которую вы получаете сейчас ...)

Обратите внимание, что isnan и isinf являются функциями, определенными в стандарте C99, и нет необходимости определять эти макросы для любого современного компилятора.

...