Skip to content

Commit

Permalink
Merge pull request #553 from Cytnx-dev/haoti/pre-releasev1.0.0
Browse files Browse the repository at this point in the history
Fix macos building error.
  • Loading branch information
hunghaoti authored Jan 4, 2025
2 parents 80cf598 + 9c1d8f9 commit 144cbf6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Available types are :
```c++
Storage A(400,Type.Double);
for(int i=0;i<400;i++)
A.at<double>(i) = i;
A.at<double>(i) = i;

Storage B = A; // A and B share same memory, this is similar to Python

Expand Down
56 changes: 28 additions & 28 deletions include/Type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> is 0.
template <typename T>
constexpr int type_size = sizeof(T);
inline constexpr int type_size = sizeof(T);
template <>
constexpr int type_size<void> = 0;
inline constexpr int type_size<void> = 0;
} // namespace internal

// the list of supported types. The dtype() of an object is an index into this list.
Expand All @@ -160,59 +160,59 @@ namespace cytnx {

// The friendly name of each type
template <typename T>
constexpr char* Type_names = nullptr;
inline constexpr char* Type_names = nullptr;
template <>
constexpr const char* Type_names<void> = "Void";
inline constexpr const char* Type_names<void> = "Void";
template <>
constexpr const char* Type_names<cytnx_complex128> = "Complex Double (Complex Float64)";
inline constexpr const char* Type_names<cytnx_complex128> = "Complex Double (Complex Float64)";
template <>
constexpr const char* Type_names<cytnx_complex64> = "Complex Float (Complex Float32)";
inline constexpr const char* Type_names<cytnx_complex64> = "Complex Float (Complex Float32)";
template <>
constexpr const char* Type_names<cytnx_double> = "Double (Float64)";
inline constexpr const char* Type_names<cytnx_double> = "Double (Float64)";
template <>
constexpr const char* Type_names<cytnx_float> = "Float (Float32)";
inline constexpr const char* Type_names<cytnx_float> = "Float (Float32)";
template <>
constexpr const char* Type_names<cytnx_int64> = "Int64";
inline constexpr const char* Type_names<cytnx_int64> = "Int64";
template <>
constexpr const char* Type_names<cytnx_uint64> = "Uint64";
inline constexpr const char* Type_names<cytnx_uint64> = "Uint64";
template <>
constexpr const char* Type_names<cytnx_int32> = "Int32";
inline constexpr const char* Type_names<cytnx_int32> = "Int32";
template <>
constexpr const char* Type_names<cytnx_uint32> = "Uint32";
inline constexpr const char* Type_names<cytnx_uint32> = "Uint32";
template <>
constexpr const char* Type_names<cytnx_int16> = "Int16";
inline constexpr const char* Type_names<cytnx_int16> = "Int16";
template <>
constexpr const char* Type_names<cytnx_uint16> = "Uint16";
inline constexpr const char* Type_names<cytnx_uint16> = "Uint16";
template <>
constexpr const char* Type_names<cytnx_bool> = "Bool";
inline constexpr const char* Type_names<cytnx_bool> = "Bool";

// The corresponding Python enumeration name
template <typename T>
constexpr char* Type_enum_name = nullptr;
inline constexpr char* Type_enum_name = nullptr;
template <>
constexpr const char* Type_enum_name<void> = "Void";
inline constexpr const char* Type_enum_name<void> = "Void";
template <>
constexpr const char* Type_enum_name<cytnx_complex128> = "ComplexDouble";
inline constexpr const char* Type_enum_name<cytnx_complex128> = "ComplexDouble";
template <>
constexpr const char* Type_enum_name<cytnx_complex64> = "ComplexFloat";
inline constexpr const char* Type_enum_name<cytnx_complex64> = "ComplexFloat";
template <>
constexpr const char* Type_enum_name<cytnx_double> = "Double";
inline constexpr const char* Type_enum_name<cytnx_double> = "Double";
template <>
constexpr const char* Type_enum_name<cytnx_float> = "Float";
inline constexpr const char* Type_enum_name<cytnx_float> = "Float";
template <>
constexpr const char* Type_enum_name<cytnx_int64> = "Int64";
inline constexpr const char* Type_enum_name<cytnx_int64> = "Int64";
template <>
constexpr const char* Type_enum_name<cytnx_uint64> = "Uint64";
inline constexpr const char* Type_enum_name<cytnx_uint64> = "Uint64";
template <>
constexpr const char* Type_enum_name<cytnx_int32> = "Int32";
inline constexpr const char* Type_enum_name<cytnx_int32> = "Int32";
template <>
constexpr const char* Type_enum_name<cytnx_uint32> = "Uint32";
inline constexpr const char* Type_enum_name<cytnx_uint32> = "Uint32";
template <>
constexpr const char* Type_enum_name<cytnx_int16> = "Int16";
inline constexpr const char* Type_enum_name<cytnx_int16> = "Int16";
template <>
constexpr const char* Type_enum_name<cytnx_uint16> = "Uint16";
inline constexpr const char* Type_enum_name<cytnx_uint16> = "Uint16";
template <>
constexpr const char* Type_enum_name<cytnx_bool> = "Bool";
inline constexpr const char* Type_enum_name<cytnx_bool> = "Bool";

struct Type_struct {
const char* name; // char* is OK here, it is only ever initialized from a string literal
Expand Down
2 changes: 1 addition & 1 deletion src/random/uniform_.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(low), static_cast<float>(low)};
} else if (Tin.dtype() == Type.Double) {
Tin += low;
} else if (Tin.dtype() == Type.Float) {
Expand Down

0 comments on commit 144cbf6

Please sign in to comment.