Skip to content

Commit

Permalink
Macaulay2 v1.23-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Mar 1, 2024
1 parent 614e1f3 commit 0e4d9d7
Showing 1 changed file with 2 additions and 68 deletions.
70 changes: 2 additions & 68 deletions Formula/macaulay2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,12 @@ class Macaulay2 < Formula
@name = "M2"
desc "Software system for algebraic geometry research"
homepage "http://macaulay2.com"
url "https://github.com/Macaulay2/M2/archive/refs/tags/release-1.23-rc1.tar.gz"
sha256 "855ee4453e5c6f346e0f248d2ebee8d0b35d806caeeab34584d21c4bc9046f32"
license any_of: ["GPL-2.0-only", "GPL-3.0-only"]
revision 2

head "https://github.com/Macaulay2/M2/archive/refs/heads/development.tar.gz"

stable do
url "https://github.com/Macaulay2/M2/archive/refs/tags/release-1.22.tar.gz"
sha256 "fededb82203d93f3f6db22db97350407fc6e55e90285cc8fa89713ff21d5c0fc"
patch do
url "https://github.com/Macaulay2/M2/commit/84c7b9f67bfdb6b821e24546ab2dd4e2455dfdbf.patch?full_index=1"
sha256 "135100251be6c1217948c74c46761d7550ed30e4dc27cce6a76a45d34a362f78"
end
end

bottle do
root_url "https://github.com/Macaulay2/homebrew-tap/releases/download/macaulay2-1.22_2"
sha256 cellar: :any, arm64_sonoma: "05e825ec9f41cc9d686c2b5518831ca69c9d1956f80e518e02e34ab807f6819e"
sha256 cellar: :any, ventura: "6f520730827d921b2f05719c43f5d260968490ab73b2240d99cc79f0a8d408b9"
sha256 cellar: :any, monterey: "76b58eacb443edb17bada3e108a8e42f568130ffe06d662ee11c4a1d767c6507"
sha256 x86_64_linux: "3e64bb7cf1677029e5374c172c81b6a8b556e762d6d3f2c3465a4c9706414f02"
end

depends_on "bison" => :build
depends_on "cmake" => :build
depends_on "ninja" => :build
Expand All @@ -39,7 +23,6 @@ class Macaulay2 < Formula
depends_on "gdbm"
depends_on "givaro"
depends_on "gmp"
depends_on "libatomic_ops"
depends_on "libxml2" unless OS.mac?
depends_on "libffi"
depends_on "mpfi"
Expand Down Expand Up @@ -176,52 +159,3 @@ def install
-Wno-cast-qual # FIXME
--
2.40.1

diff --git a/M2/Macaulay2/e/eigen.cpp b/M2/Macaulay2/e/eigen.cpp
index 26cf19de66..77748d5a8c 100644
--- a/M2/Macaulay2/e/eigen.cpp
+++ b/M2/Macaulay2/e/eigen.cpp
@@ -29,6 +29,41 @@ using MatrixXmpRR = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic>;
using MatrixXmpCC = Eigen::Matrix<std::complex<double>,Eigen::Dynamic,Eigen::Dynamic>;
#endif

+#ifdef _LIBCPP_VERSION
+/* workaround incompatibility between libc++'s implementation of complex and
+ * mpreal
+ */
+namespace eigen_mpfr {
+inline Real abs(const Complex &x) { return hypot(x.real(), x.imag()); }
+inline Complex sqrt(const Complex &x)
+{
+ Real a = abs(x);
+ const Real &xr = x.real();
+ const Real &xi = x.imag();
+ if (xi >= 0) { return Complex(sqrt((a + xr) / 2), sqrt((a - xr) / 2)); }
+ else { return Complex(sqrt((a + xr) / 2), -sqrt((a - xr) / 2)); }
+}
+inline std::complex<Real> operator/(const Complex &lhs, const Complex &rhs)
+{
+ const Real &lhsr = lhs.real();
+ const Real &lhsi = lhs.imag();
+ const Real &rhsr = rhs.real();
+ const Real &rhsi = rhs.imag();
+ Real normrhs = rhsr*rhsr+rhsi*rhsi;
+ return Complex((lhsr * rhsr + lhsi * rhsi) / normrhs,
+ (lhsi * rhsr - lhsr * rhsi) / normrhs);
+}
+inline std::complex<Real> operator*(const Complex &lhs, const Complex &rhs)
+{
+ const Real &lhsr = lhs.real();
+ const Real &lhsi = lhs.imag();
+ const Real &rhsr = rhs.real();
+ const Real &rhsi = rhs.imag();
+ return Complex(lhsr * rhsr - lhsi * rhsi, lhsi * rhsr + lhsr * rhsi);
+}
+}; // namespace eigen_mpfr
+#endif
+
namespace EigenM2 {

#ifdef NO_LAPACK
--
2.40.1

0 comments on commit 0e4d9d7

Please sign in to comment.