Skip to content

Commit

Permalink
fix issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
NoNaeAbC committed Feb 12, 2021
1 parent 2ade47b commit 3bedec2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
19 changes: 18 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ sqrt(-x), consistency, ...) in favor of speed. In the future
this library may add a safe math flag. Do not use this
library in safety critical mechanisms(encryption, aerospace,
automotive). This library has undefined behavior(e.g. an
internal division by 0) and it's not documented.
internal division by 0) and it's not documented.

C++ 14 compiler required.
41 changes: 41 additions & 0 deletions amathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -14205,6 +14205,8 @@ inline Array8Complex32 operator/(const Complex32 &lhs, const Array8Complex32 &rh
return ret;
}

#if defined(AML_USE_STD_COMPLEX)

#if defined(USE_CONCEPTS)
template<class T>
concept ComplexNumber = requires(T a, T b, Complex64 v){
Expand All @@ -14214,12 +14216,51 @@ concept ComplexNumber = requires(T a, T b, Complex64 v){
a.ln();
a.set(0, v);
};
#endif


#if defined(USE_CONCEPTS)

template<ComplexNumber C>
#else
template<class C>
#endif
inline auto log(C c) { return *c.ln(); }

#if defined(USE_CONCEPTS)

template<ComplexNumber C>
#else
template<class C>
#endif
inline auto sin(C c) { return *c.sin(); }

#if defined(USE_CONCEPTS)

template<ComplexNumber C>
#else
template<class C>
#endif
inline auto log10(C c) { return *c.log10(); }

#if defined(USE_CONCEPTS)

template<ComplexNumber C>
#else
template<class C>
#endif
inline auto tan(C c) { return *c.tan(); }

#if defined(USE_CONCEPTS)

template<ComplexNumber C>
#else
template<class C>
#endif
inline auto cos(C c) { return *c.cos(); }


#endif //std::complex compatibility


#endif //MATH_LIB_A_MATH_LIB_H
3 changes: 3 additions & 0 deletions testComplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,8 @@ int main() {
testCaseId++;


std::cout << "test complete" << std::endl;


return 0;
}

0 comments on commit 3bedec2

Please sign in to comment.