diff --git a/CMakeLists.txt b/CMakeLists.txt index 75205615..820361b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,13 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C) # C++ uses link-time optimization anyway; this enables additionally -flto=auto, # for parallel compilation -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +# It cannot enable on MacOS since it cuase bulding error when linking the library libcytnx.a. +# Error message: Error running link command: no such file or directorymake[2]: *** [CMakeFiles/cytnx.dir/build.make:3109: libcytnx.a] +IF (APPLE) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) +ELSE () + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +ENDIF () add_library(cytnx STATIC) set_property(TARGET cytnx PROPERTY C_VISIBILITY_PRESET hidden) diff --git a/Readme.md b/Readme.md index 6b7cc4dc..07aeee09 100644 --- a/Readme.md +++ b/Readme.md @@ -89,7 +89,7 @@ Available types are : ```c++ Storage A(400,Type.Double); for(int i=0;i<400;i++) -A.at(i) = i; + A.at(i) = i; Storage B = A; // A and B share same memory, this is similar to Python diff --git a/include/Type.hpp b/include/Type.hpp index dc6c7eb6..c8880af4 100644 --- a/include/Type.hpp +++ b/include/Type.hpp @@ -134,9 +134,9 @@ namespace cytnx { // type_size returns the sizeof(T) for the supported types. This is the same as // sizeof(T), except that size_type is 0. template - constexpr int type_size = sizeof(T); + inline constexpr int type_size = sizeof(T); template <> - constexpr int type_size = 0; + inline constexpr int type_size = 0; } // namespace internal // the list of supported types. The dtype() of an object is an index into this list. @@ -160,59 +160,59 @@ namespace cytnx { // The friendly name of each type template - constexpr char* Type_names = nullptr; + inline constexpr char* Type_names = nullptr; template <> - constexpr const char* Type_names = "Void"; + inline constexpr const char* Type_names = "Void"; template <> - constexpr const char* Type_names = "Complex Double (Complex Float64)"; + inline constexpr const char* Type_names = "Complex Double (Complex Float64)"; template <> - constexpr const char* Type_names = "Complex Float (Complex Float32)"; + inline constexpr const char* Type_names = "Complex Float (Complex Float32)"; template <> - constexpr const char* Type_names = "Double (Float64)"; + inline constexpr const char* Type_names = "Double (Float64)"; template <> - constexpr const char* Type_names = "Float (Float32)"; + inline constexpr const char* Type_names = "Float (Float32)"; template <> - constexpr const char* Type_names = "Int64"; + inline constexpr const char* Type_names = "Int64"; template <> - constexpr const char* Type_names = "Uint64"; + inline constexpr const char* Type_names = "Uint64"; template <> - constexpr const char* Type_names = "Int32"; + inline constexpr const char* Type_names = "Int32"; template <> - constexpr const char* Type_names = "Uint32"; + inline constexpr const char* Type_names = "Uint32"; template <> - constexpr const char* Type_names = "Int16"; + inline constexpr const char* Type_names = "Int16"; template <> - constexpr const char* Type_names = "Uint16"; + inline constexpr const char* Type_names = "Uint16"; template <> - constexpr const char* Type_names = "Bool"; + inline constexpr const char* Type_names = "Bool"; // The corresponding Python enumeration name template - constexpr char* Type_enum_name = nullptr; + inline constexpr char* Type_enum_name = nullptr; template <> - constexpr const char* Type_enum_name = "Void"; + inline constexpr const char* Type_enum_name = "Void"; template <> - constexpr const char* Type_enum_name = "ComplexDouble"; + inline constexpr const char* Type_enum_name = "ComplexDouble"; template <> - constexpr const char* Type_enum_name = "ComplexFloat"; + inline constexpr const char* Type_enum_name = "ComplexFloat"; template <> - constexpr const char* Type_enum_name = "Double"; + inline constexpr const char* Type_enum_name = "Double"; template <> - constexpr const char* Type_enum_name = "Float"; + inline constexpr const char* Type_enum_name = "Float"; template <> - constexpr const char* Type_enum_name = "Int64"; + inline constexpr const char* Type_enum_name = "Int64"; template <> - constexpr const char* Type_enum_name = "Uint64"; + inline constexpr const char* Type_enum_name = "Uint64"; template <> - constexpr const char* Type_enum_name = "Int32"; + inline constexpr const char* Type_enum_name = "Int32"; template <> - constexpr const char* Type_enum_name = "Uint32"; + inline constexpr const char* Type_enum_name = "Uint32"; template <> - constexpr const char* Type_enum_name = "Int16"; + inline constexpr const char* Type_enum_name = "Int16"; template <> - constexpr const char* Type_enum_name = "Uint16"; + inline constexpr const char* Type_enum_name = "Uint16"; template <> - constexpr const char* Type_enum_name = "Bool"; + inline constexpr const char* Type_enum_name = "Bool"; struct Type_struct { const char* name; // char* is OK here, it is only ever initialized from a string literal diff --git a/src/random/uniform_.cpp b/src/random/uniform_.cpp index f4101886..113c1902 100644 --- a/src/random/uniform_.cpp +++ b/src/random/uniform_.cpp @@ -39,7 +39,7 @@ namespace cytnx { if (Tin.dtype() == Type.ComplexDouble) { Tin += cytnx_complex128{low, low}; } else if (Tin.dtype() == Type.ComplexFloat) { - Tin += cytnx_complex64{low, low}; + Tin += cytnx_complex64{static_cast(low), static_cast(low)}; } else if (Tin.dtype() == Type.Double) { Tin += low; } else if (Tin.dtype() == Type.Float) {