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 Jan 15, 2024
1 parent 1c0b0ef commit f59c47c
Showing 1 changed file with 6 additions and 59 deletions.
65 changes: 6 additions & 59 deletions Formula/macaulay2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ class Macaulay2 < Formula
@name = "M2"
desc "Software system for algebraic geometry research"
homepage "http://macaulay2.com"
url "https://github.com/Macaulay2/M2/archive/refs/heads/master.tar.gz"
version "1.23-rc1"
sha256 "e39a1941ed3eb93becc7a592dc50a273ac872ae8b42be13def40ec5f02f45243"
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, ventura: "6f520730827d921b2f05719c43f5d260968490ab73b2240d99cc79f0a8d408b9"
Expand Down Expand Up @@ -64,6 +57,9 @@ class Macaulay2 < Formula
patch :DATA

def install
# Only for release candidate
inreplace "M2/VERSION", "1.22", "1.23"

# Don't print the shims prefix path
inreplace "M2/Macaulay2/packages/Macaulay2Doc/functions/findProgram-doc.m2", "Verbose => true", "Verbose => false"

Expand Down Expand Up @@ -175,52 +171,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 f59c47c

Please sign in to comment.