Thread: C++ - Quantlib: error C2064: term does not evaluate to a function taking 1 arguments

  1. #1
    Registered User
    Join Date
    Dec 2014
    Posts
    5

    C++ - Quantlib: error C2064: term does not evaluate to a function taking 1 arguments

    Hi All,

    Kindly assist and thank you in advance.

    The first call of my function works with empty vectors but fails when dimensions are introduced to the vectors.

    When "uncommented, the commented out function call fails with the error above.

    These links might be help for those unfamiliar to QuantLib:

    https://github.com/lballabio/quantli...astsquares.hpp

    QuantLib: GeneralLinearLeastSquares Class Reference



    Code:
    #include "stdafx.h"
    #include "boost/multi_array.hpp"
    #include <cassert>
    #include <ql\math\generallinearleastsquares.hpp>
    #include <vector>
    #include <list>
    #include <iostream>
    #include "boost\lambda\lambda.hpp"
    
    
    
    
    using namespace std;
    using namespace QuantLib;
    
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        
    QuantLib::GeneralLinearLeastSquares t (vector<int> (), vector <int> (), vector <int> ());
    
    
    
    
    vector<int> xVec(2);
    vector <int> yVec(2);
    vector <int> vVec(4);
    
    
    //QuantLib::GeneralLinearLeastSquares test(xVec, yVec, vVec);  // This does not run
    
    
    int done;
    cin >> done;
    
    
    
    
    return 0;
    }

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Can you post the complete error message? There should be some information on exactly what line and source file it is, plus a traceback.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Dec 2014
    Posts
    5
    Hi Elysia,

    This is the error message:

    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(1043): error C2064: term does not evaluate to a function taking 1 arguments
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(1081) : see reference to function template instantiation '_OutIt std::_Transform<_InIt,_Iter,_Fn1>(_InIt,_InIt,_Out It,_Fn1)' being compiled
    1> with
    1> [
    1> _OutIt=QuantLib::Matrix::column_iterator,
    1> _InIt=const int *,
    1> _Iter=QuantLib::Matrix::column_iterator,
    1> _Fn1=int
    1> ]

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There should be more in the backtrace. I can only see the error happening in a system header, not which function called it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Dec 2014
    Posts
    5
    1>------ Build started: Project: TestingQuantLib, Configuration: Debug Win32 ------
    1> TestingQuantLib.cpp
    1>c:\local\quantlib-1.4\testingquantlib\testingquantlib.cpp(139): warning C4930: 'QuantLib::GeneralLinearLeastSquares t(std::vector<_Ty> (__cdecl *)(void),std::vector<_Ty> (__cdecl *)(void),std::vector<_Ty> (__cdecl *)(void))': prototyped function not called (was a variable definition intended?)
    1> with
    1> [
    1> _Ty=int
    1> ]
    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\numeric(106): warning C4996: 'std::_Inner_product1': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\numeric(90) : see declaration of 'std::_Inner_product1'
    1> c:\local\quantlib-1.4\quantlib-1.4\ql\math\array.hpp(475) : see reference to function template instantiation '_Ty std::inner_product<QuantLib::Array::const_iterator ,QuantLib::Array::const_iterator,double>(_InIt1,_I nIt1,_InIt2,_Ty)' being compiled
    1> with
    1> [
    1> _Ty=double,
    1> _InIt1=QuantLib::Array::const_iterator,
    1> _InIt2=QuantLib::Array::const_iterator
    1> ]
    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\numeric(106): warning C4996: 'std::_Inner_product1': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\numeric(90) : see declaration of 'std::_Inner_product1'
    1> c:\local\quantlib-1.4\quantlib-1.4\ql\math\matrix.hpp(507) : see reference to function template instantiation '_Ty std::inner_product<QuantLib::Array::const_iterator ,QuantLib::Matrix::const_column_iterator,double>(_ InIt1,_InIt1,_InIt2,_Ty)' being compiled
    1> with
    1> [
    1> _Ty=double,
    1> _InIt1=QuantLib::Array::const_iterator,
    1> _InIt2=QuantLib::Matrix::const_column_iterator
    1> ]
    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\numeric(106): warning C4996: 'std::_Inner_product1': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\numeric(90) : see declaration of 'std::_Inner_product1'
    1> c:\local\quantlib-1.4\quantlib-1.4\ql\math\generallinearleastsquares.hpp(152) : see reference to function template instantiation '_Ty std::inner_product<QuantLib::Array::iterator,Quant Lib::Array::iterator,double>(_InIt1,_InIt1,_InIt2, _Ty)' being compiled
    1> with
    1> [
    1> _Ty=double,
    1> _InIt1=QuantLib::Array::iterator,
    1> _InIt2=QuantLib::Array::iterator
    1> ]
    1> c:\local\quantlib-1.4\quantlib-1.4\ql\math\generallinearleastsquares.hpp(93) : see reference to function template instantiation 'void QuantLib::GeneralLinearLeastSquares::calculate<std ::_Vector_const_iterator<_Myvec>,std::_Vector_cons t_iterator<_Myvec>,std::_Vector_const_iterator<_My vec>>(xIterator,xIterator,yIterator,yIterator,vIte rator,vIterator)' being compiled
    1> with
    1> [
    1> _Myvec=std::_Vector_val<int,std::allocator<int>>,
    1> xIterator=std::_Vector_const_iterator<std::_Vector _val<int,std::allocator<int>>>,
    1> yIterator=std::_Vector_const_iterator<std::_Vector _val<int,std::allocator<int>>>,
    1> vIterator=std::_Vector_const_iterator<std::_Vector _val<int,std::allocator<int>>>
    1> ]
    1> c:\local\quantlib-1.4\testingquantlib\testingquantlib.cpp(146) : see reference to function template instantiation 'QuantLib::GeneralLinearLeastSquares::GeneralLinea rLeastSquares<std::vector<_Ty>,std::vector<_Ty>,st d::vector<_Ty>>(const xContainer &,const yContainer &,const vContainer &)' being compiled
    1> with
    1> [
    1> _Ty=int,
    1> xContainer=std::vector<int>,
    1> yContainer=std::vector<int>,
    1> vContainer=std::vector<int>
    1> ]
    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(1043): error C2064: term does not evaluate to a function taking 1 arguments
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(1081) : see reference to function template instantiation '_OutIt std::_Transform<_InIt,_Iter,_Fn1>(_InIt,_InIt,_Out It,_Fn1)' being compiled
    1> with
    1> [
    1> _OutIt=QuantLib::Matrix::column_iterator,
    1> _InIt=const int *,
    1> _Iter=QuantLib::Matrix::column_iterator,
    1> _Fn1=int
    1> ]
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(1105) : see reference to function template instantiation '_OutIt std::_Transform1<_InIt,_OutIt,_Fn1>(_InIt,_InIt,_O utIt,_Fn1,std::random_access_iterator_tag,std::ran dom_access_iterator_tag)' being compiled
    1> with
    1> [
    1> _OutIt=QuantLib::Matrix::column_iterator,
    1> _InIt=const int *,
    1> _Fn1=int
    1> ]
    1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(1119) : see reference to function template instantiation '_OutIt std::_Transform1<const int*,_OutIt,_Fn1>(_InIt,_InIt,_OutIt,_Fn1,std::tr1 ::false_type)' being compiled
    1> with
    1> [
    1> _OutIt=QuantLib::Matrix::column_iterator,
    1> _Fn1=int,
    1> _InIt=const int *
    1> ]
    1> c:\local\quantlib-1.4\quantlib-1.4\ql\math\generallinearleastsquares.hpp(125) : see reference to function template instantiation '_OutIt std::transform<xIterator,QuantLib::Matrix::column_ iterator,int>(_InIt,_InIt,_OutIt,_Fn1)' being compiled
    1> with
    1> [
    1> _OutIt=QuantLib::Matrix::column_iterator,
    1> xIterator=std::_Vector_const_iterator<std::_Vector _val<int,std::allocator<int>>>,
    1> _InIt=std::_Vector_const_iterator<std::_Vector_val <int,std::allocator<int>>>,
    1> _Fn1=int
    1> ]
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  6. #6
    Registered User
    Join Date
    Dec 2014
    Posts
    5
    Would that what you are asking for it Elysia?

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes. Let me see if I can make sense of it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    OK, so good news is that I've figured out what's wrong.
    Bad news is that I don't know how to properly use it (or there's a bug).

    >>QuantLib::GeneralLinearLeastSquares t (vector<int> (), vector <int> (), vector <int> ());
    So this compiles because it's a function declaration.

    >>QuantLib::GeneralLinearLeastSquares test(xVec, yVec, vVec); // This does not run
    This does not compile because there's a call in the code to std::transform:
    std::transform(xBegin, xEnd, A.column_begin(i), *vBegin++);
    The code passes 4 iterators to the function, which is wrong.
    transform accepts 3 iterators and a unary function (to perform the transformation).
    It can also accept 4 iterators for two ranges and a binary function to perform the transformation.
    Simply put, the library is using the function wrong and I can't find any example or documentation on how to use this code properly.
    It may be a bug.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Dec 2014
    Posts
    5
    Elysia, thank you very much for your help. If I do find a solution I will post it here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 08-24-2011, 10:26 AM
  2. Replies: 1
    Last Post: 06-14-2010, 01:27 PM
  3. Replies: 1
    Last Post: 06-14-2010, 01:26 PM
  4. Replies: 4
    Last Post: 10-25-2009, 05:06 PM
  5. Replies: 9
    Last Post: 10-20-2008, 10:23 AM

Tags for this Thread