Registered Member
|
I am new to Eigen. Can someone explain why line 3 below does not compile (line 2 is fine)?
VectorXcd v(3); complex<double> t1 = v.transpose()*v; t1 = v.transpose()*v; I am running this on MacOS 10.8.3 using Xcode 4.6.2. The error message is No viable conversion from 'const typename ProductReturnType<CwiseUnaryOp<scalar_conjugate_op<complex<double> >, const Transpose<const Matrix<complex<double>, -1, 1, 0, -1, 1> > >, Matrix<complex<double>, -1, 1, 0, -1, 1> >::Type' (aka 'const GeneralProduct<Eigen::CwiseUnaryOp<Eigen::internal::scalar_conjugate_op<std::__1::complex<double> >, const Eigen::Transpose<const Eigen::Matrix<std::__1::complex<double>, -1, 1, 0, -1, 1> > >, Eigen::Matrix<std::__1::complex<double>, -1, 1, 0, -1, 1>, 3>') to 'std::__1::complex<double>' Thanks... |
Moderator
|
Works fine for me with gcc and clang. Also, the error message does not seem to match the line your are pointing out because it presents a CwiseUnaryOp<scalar_conjugate_op<complex<double> > (produced by a .conjugate() or .adjoint()).
|
Registered Member
|
Thanks,
Based on this I changed the compiler option from Apple LLVM compiler 4.2 (default) to LLVM GCC 4.2, and it compiles fine. You are correct about the mismatch, that was from a line using adjoint() instead of transpose(). I am beginning to learn my lesson: never use the Apple compiler. Here is the code and the error if I do (with 2 lines producing essentially the same error: #include <iostream> #include <complex> #include <Eigen/Dense> int main(int argc, const char * argv[]) { Eigen::VectorXcd vc2(3); std::complex<double> t1 = vc2.transpose()*vc2;//Okay std::complex<double> t2 (vc2.transpose()*vc2); //error t1 = vc2.transpose()*vc2; //error return 0; } /* Error message: .../main.cpp:10:10: No viable conversion from 'const typename ProductReturnType<Transpose<Matrix<complex<double>, -1, 1, 0, -1, 1> >, Matrix<complex<double>, -1, 1, 0, -1, 1> >::Type' (aka 'const GeneralProduct<Eigen::Transpose<Eigen::Matrix<std::__1::complex<double>, -1, 1, 0, -1, 1> >, Eigen::Matrix<std::__1::complex<double>, -1, 1, 0, -1, 1>, 3>') to 'std::__1::complex<double>' */ |
Moderator
|
I'm still surprised. Your example does compile fine with "Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)". What are the compilation flags?
|
Registered Member
|
Not sure I grasp all the compiler options, but it still is not working for me. Here is what I get by copying the compiler options from the Xcode target, if that helps you understand what is going on:
//:configuration = Debug GCC_VERSION = com.apple.compilers.llvm.clang.1_0 //:configuration = Release GCC_VERSION = com.apple.compilers.llvm.clang.1_0 //:completeSettings = some BUILD_VARIANTS GCC_VERSION DEBUG_INFORMATION_FORMAT GENERATE_PROFILING_CODE PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR RUN_CLANG_STATIC_ANALYZER SCAN_ALL_SOURCE_FILES_FOR_INCLUDES VALIDATE_PRODUCT GCC_FAST_OBJC_DISPATCH CLANG_X86_VECTOR_INSTRUCTIONS GCC_STRICT_ALIASING GCC_GENERATE_DEBUGGING_SYMBOLS GCC_DYNAMIC_NO_PIC GCC_GENERATE_TEST_COVERAGE_FILES GCC_INLINES_ARE_PRIVATE_EXTERN GCC_INSTRUMENT_PROGRAM_FLOW_ARCS GCC_ENABLE_KERNEL_DEVELOPMENT LLVM_LTO GCC_REUSE_STRINGS GCC_NO_COMMON_BLOCKS GCC_OPTIMIZATION_LEVEL GCC_FAST_MATH GCC_THREADSAFE_STATICS GCC_SYMBOLS_PRIVATE_EXTERN GCC_UNROLL_LOOPS GCC_CHAR_IS_UNSIGNED_CHAR GCC_ENABLE_ASM_KEYWORD GCC_C_LANGUAGE_STANDARD CLANG_CXX_LANGUAGE_STANDARD CLANG_CXX_LIBRARY GCC_CW_ASM_SYNTAX GCC_INPUT_FILETYPE GCC_ENABLE_CPP_EXCEPTIONS GCC_ENABLE_CPP_RTTI GCC_LINK_WITH_DYNAMIC_LIBRARIES GCC_ENABLE_OBJC_EXCEPTIONS GCC_ENABLE_TRIGRAPHS GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS GCC_USE_INDIRECT_FUNCTION_CALLS GCC_USE_REGISTER_FUNCTION_CALLS CLANG_LINK_OBJC_RUNTIME GCC_INCREASE_PRECOMPILED_HEADER_SHARING CLANG_ENABLE_OBJC_ARC OTHER_CFLAGS OTHER_CPLUSPLUSFLAGS GCC_PRECOMPILE_PREFIX_HEADER GCC_PREFIX_HEADER GCC_ENABLE_BUILTIN_FUNCTIONS GCC_ENABLE_PASCAL_STRINGS GCC_SHORT_ENUMS GCC_USE_STANDARD_INCLUDE_SEARCHING GCC_PREPROCESSOR_DEFINITIONS GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS GCC_WARN_INHIBIT_ALL_WARNINGS GCC_WARN_PEDANTIC GCC_TREAT_WARNINGS_AS_ERRORS GCC_WARN_CHECK_SWITCH_STATEMENTS GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS CLANG_WARN_EMPTY_BODY GCC_WARN_FOUR_CHARACTER_CONSTANTS GCC_WARN_SHADOW CLANG_WARN_CONSTANT_CONVERSION GCC_WARN_64_TO_32_BIT_CONVERSION CLANG_WARN_ENUM_CONVERSION CLANG_WARN_INT_CONVERSION CLANG_WARN_IMPLICIT_SIGN_CONVERSION GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED GCC_WARN_ABOUT_RETURN_TYPE GCC_WARN_MISSING_PARENTHESES GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS GCC_WARN_ABOUT_MISSING_PROTOTYPES GCC_WARN_ABOUT_MISSING_NEWLINE WARNING_CFLAGS GCC_WARN_ABOUT_POINTER_SIGNEDNESS GCC_WARN_SIGN_COMPARE CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS GCC_WARN_TYPECHECK_CALLS_TO_PRINTF GCC_WARN_UNINITIALIZED_AUTOS GCC_WARN_UNKNOWN_PRAGMAS GCC_WARN_UNUSED_FUNCTION GCC_WARN_UNUSED_LABEL GCC_WARN_UNUSED_PARAMETER GCC_WARN_UNUSED_VALUE GCC_WARN_UNUSED_VARIABLE CLANG_WARN__EXIT_TIME_DESTRUCTORS GCC_WARN_NON_VIRTUAL_DESTRUCTOR GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO CLANG_WARN_CXX0X_EXTENSIONS |
Moderator
|
It seems the issue shows up with -std=c++11 only. I reported to clang's team: http://llvm.org/bugs/show_bug.cgi?id=16042.
|
Registered Member
|
Thanks for looking into this. I guess in the meantime I will just have to define lots of local variables since that seems to be the only way I can get the assignment to work.
|
Moderator
|
You have many options:
- disable c++11 - use v1.dot(v2) - use (v1.transpose()*v2).value() - use (v1.transpose()*v2)[0] |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]