Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346/***************************************************************************1**2*A gauss.c gauss-package Max Neunhoeffer3**4*/56/* Try to use as much of the GNU C library as possible: */7#define _GNU_SOURCE89#include "src/compiled.h" /* GAP headers */1011/* The following seems to be necessary to run under modern gcc compilers12* which have the ssp stack checking enabled. Hopefully this does not13* hurt in future or other versions... */14#if 015#ifdef __GNUC__16#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))17extern void __stack_chk_fail();18void __stack_chk_fail_local (void)19{20__stack_chk_fail ();21}22#endif23#endif24#endif2526Obj FuncSYMMETRIC_DIFFERENCE_OF_ORDERED_SETS_OF_SMALL_INTEGERS( Obj self, Obj a, Obj b )27{28Obj c; /* for the result */29Int len,lena,lenb;30Int i,j,k;31Int x,y;3233lena = LEN_PLIST(a);34lenb = LEN_PLIST(b);35len = lena+lenb;36if (len == 0) {37return NEW_PLIST(T_PLIST_EMPTY,0);38}39c = NEW_PLIST(T_PLIST_CYC_SSORT,len);40SET_LEN_PLIST(c,len);41i = 1;42j = 1;43k = 1;44if (i <= lena && j <= lenb) {45x = INT_INTOBJ(ELM_PLIST(a,i));46y = INT_INTOBJ(ELM_PLIST(b,j));47while (1) {48if (x < y) {49SET_ELM_PLIST(c,k,INTOBJ_INT(x));50k++;51i++;52if (i > lena)53break;54else55x = INT_INTOBJ(ELM_PLIST(a,i));56} else if (y < x) {57SET_ELM_PLIST(c,k,INTOBJ_INT(y));58k++;59j++;60if (j > lenb)61break;62else63y = INT_INTOBJ(ELM_PLIST(b,j));64} else {65i++;66j++;67if (i > lena)68break;69else70x = INT_INTOBJ(ELM_PLIST(a,i));71if (j > lenb)72break;73else74y = INT_INTOBJ(ELM_PLIST(b,j));75}76}77}78/* Only one of the following will happen: */79while (i <= lena) {80SET_ELM_PLIST(c,k,ELM_PLIST(a,i));81i++;82k++;83}84while (j <= lenb) {85SET_ELM_PLIST(c,k,ELM_PLIST(b,j));86j++;87k++;88}89SET_LEN_PLIST(c,k-1);90SHRINK_PLIST(c,k-1);91return c;92}939495/*F * * * * * * * * * * * * * initialize package * * * * * * * * * * * * * * */9697/******************************************************************************98*V GVarFuncs . . . . . . . . . . . . . . . . . . list of functions to export99*/100static StructGVarFunc GVarFuncs [] = {101102{ "SYMMETRIC_DIFFERENCE_OF_ORDERED_SETS_OF_SMALL_INTEGERS", 2, "a, b",103FuncSYMMETRIC_DIFFERENCE_OF_ORDERED_SETS_OF_SMALL_INTEGERS,104"gauss.c:SYMMETRIC_DIFFERENCE_OF_ORDERED_SETS_OF_SMALL_INTEGERS" },105106{ 0 }107108};109110/******************************************************************************111*F InitKernel( <module> ) . . . . . . . . initialise kernel data structures112*/113static Int InitKernel ( StructInitInfo *module )114{115/* init filters and functions */116InitHdlrFuncsFromTable( GVarFuncs );117118/* return success */119return 0;120}121122/******************************************************************************123*F InitLibrary( <module> ) . . . . . . . initialise library data structures124*/125static Int InitLibrary ( StructInitInfo *module )126{127/* init functions */128InitGVarFuncsFromTable(GVarFuncs);129130/* return success */131return 0;132}133134/******************************************************************************135*F InitInfopl() . . . . . . . . . . . . . . . . . table of init functions136*/137static StructInitInfo module = {138#ifdef GAUSSSTATIC139.type = MODULE_STATIC,140#else141.type = MODULE_DYNAMIC,142#endif143.name = "gauss",144.initKernel = InitKernel,145.initLibrary = InitLibrary,146};147148#ifndef GAUSSSTATIC149StructInitInfo * Init__Dynamic ( void )150{151return &module;152}153#endif154155StructInitInfo * Init__gauss ( void )156{157return &module;158}159160161/*162*163* This program is free software; you can redistribute it and/or modify164* it under the terms of the GNU General Public License as published by165* the Free Software Foundation; version 2 of the License.166*167* This program is distributed in the hope that it will be useful,168* but WITHOUT ANY WARRANTY; without even the implied warranty of169* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the170* GNU General Public License for more details.171*172* You should have received a copy of the GNU General Public License173* along with this program; if not, write to the Free Software174* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA175*176*/177178179