From 6c8b14d6877e9ae553806937efecfd14f150632a Mon Sep 17 00:00:00 2001 From: Jerry James Date: Aug 12 2019 21:08:57 +0000 Subject: Build a shared library for sagemath. - Add -devel and -tools subpackages. - Add a check script. --- diff --git a/coxeter-shared.patch b/coxeter-shared.patch new file mode 100644 index 0000000..e58bbfd --- /dev/null +++ b/coxeter-shared.patch @@ -0,0 +1,62 @@ +--- makefile.orig 2018-02-26 14:57:36.000000000 -0700 ++++ makefile 2019-08-12 11:47:02.304905154 -0600 +@@ -1,14 +1,14 @@ + # sources contains a list of the source files (i.e., the .cpp files) + sources := $(patsubst %.cpp,%.cpp,$(wildcard *.cpp)) + # there is one .o file for each .cpp file +-objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp)) ++objects := $(patsubst %.cpp,%.o,$(filter-out main.cpp, $(wildcard *.cpp))) + # this is used to automatically generate the dependencies + dependencies := $(patsubst %.cpp,%.d,$(wildcard *.cpp)) + + globals = globals.h + + pflags = -c $(includedirs) -pg -O +-oflags = -c $(includedirs) -O -Wall ++oflags = -c $(includedirs) -fPIC $(CXXFLAGS) + gflags = -c $(includedirs) -g + + cflags = $(gflags) # the default setting +@@ -22,18 +22,28 @@ ifdef profile + cflags = $(pflags) + endif + +-cc = g++ ++EXENAME = coxeter ++LIBNAME = coxeter3 ++LIBPREFIX = lib ++LIBDIR = $(libdir) ++LINKFLAGS = $(LDFLAGS) -shared -Wl,-soname,libcoxeter3.so.0 ++LIBRARY = $(LIBPREFIX)$(LIBNAME).so.0.0.0 + +-all: coxeter #clean ++all: $(LIBRRAY) $(EXENAME) + +-coxeter: $(objects) +- $(cc) -o coxeter $(objects) ++$(LIBRARY): $(objects) ++ $(CXX) $(CXXFLAGS) $(LINKFLAGS) -o $@ $(objects) ++ ln -s $(LIBPREFIX)$(LIBNAME).so.0.0.0 $(LIBPREFIX)$(LIBNAME).so.0 ++ ln -s $(LIBPREFIX)$(LIBNAME).so.0 $(LIBPREFIX)$(LIBNAME).so ++ ++$(EXENAME): $(LIBRARY) main.o ++ $(CXX) $(CXXFLAGS) $(LDFLAGS) main.o -o $@ -L. -l$(LIBNAME) + + clean: + rm -f $(objects) + + %.o:%.cpp +- $(cc) $(cflags) $*.cpp ++ $(CXX) $(cflags) $*.cpp + + # dependencies --- these were generated automatically by make depend on my + # system; they are explicitly copied for portability. Only local dependencies +@@ -43,7 +53,7 @@ clean: + # contents of tmp in lieu of the dependencies listed here. + + %.d:%.cpp +- @$(cc) -MM $*.cpp ++ @$(CXX) -MM $*.cpp + depend: $(dependencies) + + affine.o: affine.cpp affine.h globals.h coxgroup.h coxtypes.h io.h list.h \ diff --git a/coxeter.spec b/coxeter.spec index 1a50416..d0a1ab8 100644 --- a/coxeter.spec +++ b/coxeter.spec @@ -6,19 +6,45 @@ Name: coxeter Version: 3.1 -Release: 2.%{gitdate}.%{shorttag}%{?dist} +Release: 3.%{gitdate}.%{shorttag}%{?dist} Summary: Combinatorial aspects of Coxeter group theory License: GPL+ URL: https://github.com/%{owner}/%{name} Source0: %{url}/archive/%{gittag}/%{name}-%{shorttag}.tar.gz +# See https://github.com/tscrim/coxeter/pull/14 +Source1: sage.h +Source2: sage.cpp +# Test files from the sagemath project +Source3: test.input +Source4: test.output.expected # Store the runtime data in a more canonical place Patch0: %{name}-data.patch +# Build a shared library for use by sagemath +Patch1: %{name}-shared.patch BuildRequires: gcc-c++ BuildRequires: tex(latex) %description +This package contains a library that enables exploration of +combinatorial issues related to Coxeter groups and Hecke algebras, with +a particular emphasis on the computation of Kazhdan-lusztig polynomials +and related questions. + +%package devel +Summary: Header files and library links for coxeter +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +Header files and library links for developing applications that use +the coxeter library. + +%package tools +Summary: Coxeter command line tools +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description tools Coxeter is a program for the exploration of combinatorial issues related to Coxeter groups and Hecke algebras, with a particular emphasis on the computation of Kazhdan-lusztig polynomials and related questions. It is @@ -27,18 +53,23 @@ a direct C++ implementation of the concept of a Coxeter group. %prep %autosetup -p0 -n %{name}-%{gittag} - -# Use our build and linker flags -sed -e 's|-O -Wall|%{optflags}|' \ - -e "s|coxeter \$(objects)|& $RPM_LD_FLAGS|" \ - -i makefile +cp -p %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} . %build -%make_build optimize=true +%make_build optimize=true libdir=%{_libdir} \ + CXX=g++ CXXFLAGS="%{optflags}" LDFLAGS="$RPM_LD_FLAGS" pdflatex INTRO.tex pdflatex INTRO.tex %install +# Install the library +mkdir -p %{buildroot}%{_libdir} +cp -a libcoxeter3.so* %{buildroot}%{_libdir} + +# Install the header files +mkdir -p %{buildroot}%{_includedir}/%{name} +cp -p *.h *.hpp %{buildroot}%{_includedir}/%{name} + # Install the binary mkdir -p %{buildroot}%{_bindir} cp -p coxeter %{buildroot}%{_bindir} @@ -47,12 +78,32 @@ cp -p coxeter %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_datadir}/%{name} cp -a coxeter_matrices headers messages %{buildroot}%{_datadir}/%{name} +%check +LD_LIBRARY_PATH=$PWD ./coxeter < test.input > test.output +if ! diff test.output.expected test.output > /dev/null; then + echo >&2 "Error testing coxeter on test.input:" + diff -u test.output.expected test.output + exit 1 +fi + %files %doc INTRO.pdf README -%{_bindir}/%{name} +%{_libdir}/libcoxeter3.so.* %{_datadir}/%{name}/ +%files devel +%{_includedir}/%{name}/ +%{_libdir}/libcoxeter3.so + +%files tools +%{_bindir}/%{name} + %changelog +* Mon Aug 12 2019 Jerry James - 3.1-3.20180226.7b5a1f0 +- Build a shared library for sagemath +- Add -devel and -tools subpackages +- Add a check script + * Wed Jul 24 2019 Fedora Release Engineering - 3.1-2.20180226.7b5a1f0 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild diff --git a/sage.cpp b/sage.cpp new file mode 100644 index 0000000..74f86be --- /dev/null +++ b/sage.cpp @@ -0,0 +1,56 @@ +/* + Coxeter version 3.0 Copyright (C) 2009 Mike Hansen + See file main.cpp for full copyright notice +*/ + +#include "sage.h" + +namespace sage { + + void interval(List& list, CoxGroup& W, const CoxWord& g, const CoxWord& h) + + /* + Returns a list of the elements in the Bruhat interval between g and h. + Note that this assumes that g and h are in order. + */ + { + if (not W.inOrder(g,h)) { + return; + } + + W.extendContext(h); + + CoxNbr x = W.contextNumber(g); + CoxNbr y = W.contextNumber(h); + + BitMap b(W.contextSize()); + W.extractClosure(b,y); + + BitMap::ReverseIterator b_rend = b.rend(); + List res(0); + + for (BitMap::ReverseIterator i = b.rbegin(); i != b_rend; ++i) + if (not W.inOrder(x,*i)) { + BitMap bi(W.contextSize()); + W.extractClosure(bi,*i); + CoxNbr z = *i; // andnot will invalidate iterator + b.andnot(bi); + b.setBit(z); // otherwise the decrement will not be correct + } else + res.append(*i); + + schubert::NFCompare nfc(W.schubert(),W.ordering()); + Permutation a(res.size()); + sortI(res,nfc,a); + + list.setSize(0); + for (size_t j = 0; j < res.size(); ++j) { + CoxWord w(0); + W.schubert().append(w, res[a[j]]); + list.append(w); + } + + return; + } + +} diff --git a/sage.h b/sage.h new file mode 100644 index 0000000..5b3df8a --- /dev/null +++ b/sage.h @@ -0,0 +1,23 @@ +/* + Coxeter version 3.0 Copyright (C) 2009 Mike Hansen + See file main.cpp for full copyright notice +*/ + +#ifndef SAGE_H /* guard against multiple inclusions */ +#define SAGE_H + +#include "globals.h" +#include "coxgroup.h" +#include "coxtypes.h" +#include "schubert.h" +#include "list.h" + +namespace sage { + using namespace coxeter; + using namespace coxtypes; + using namespace list; + + void interval(List& result, CoxGroup& W, const CoxWord& g, const CoxWord& h); +} + +#endif diff --git a/test.input b/test.input new file mode 100644 index 0000000..fb73236 --- /dev/null +++ b/test.input @@ -0,0 +1,9 @@ +type +A +3 +compute +1 3 2 1 2 3 1 2 1 +ihbetti +213 +q +q diff --git a/test.output.expected b/test.output.expected new file mode 100644 index 0000000..b97ee09 --- /dev/null +++ b/test.output.expected @@ -0,0 +1,13 @@ +This is Coxeter version 3.1. +Enter help if you need assistance, carriage return to start the program. + +coxeter : +type : +rank : coxeter : enter your element (finish with a carriage return) : +213 +coxeter : enter your element (finish with a carriage return) : +h[0] = 1 h[1] = 3 h[2] = 3 h[3] = 1 + +size : 8 + +coxeter : coxeter : \ No newline at end of file