Skip to content

Commit

Permalink
Fixing dirty hacks (map -> ideal) for fast_map
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Motsak committed May 27, 2015
1 parent 794d7ba commit bf36c43
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
9 changes: 8 additions & 1 deletion Singular/ipshell.cc
Expand Up @@ -67,6 +67,7 @@

#include <math.h>
#include <ctype.h>
#include <algorithm>

// define this if you want to use the fast_map routine for mapping ideals
#define FAST_MAP
Expand Down Expand Up @@ -780,7 +781,13 @@ leftv iiMap(map theMap, const char * what)
)
{
v->rtyp=IDEAL_CMD;
v->data=fast_map(IDIDEAL(w), src_ring, (ideal)theMap, currRing);

char *tmp = (char*)1;
std::swap(tmp, theMap->preimage); // map gets 1 as its rank (as an ideal)
v->data=fast_map(IDIDEAL(w), src_ring, (ideal)theMap, currRing); // FIXME: this dirty hack from original Singular!
std::swap(tmp, theMap->preimage); // map gets its preimage back
assume( tmp == (char*)1 );

}
else
#endif
Expand Down
9 changes: 8 additions & 1 deletion Singular/maps_ip.cc
Expand Up @@ -43,6 +43,7 @@
#include <polys/monomials/maps.h>
#endif

#include <algorithm>

/*2
* maps the expression w to res,
Expand Down Expand Up @@ -390,7 +391,13 @@ poly pSubstPoly(poly p, int var, poly image)
{
ideal src_id=idInit(1,1);
src_id->m[0]=p;
ideal res_id=fast_map(src_id,currRing,(ideal)theMap,currRing);

char *tmp = (char*)1;
std::swap(tmp, theMap->preimage); // map gets 1 as its rank (as an ideal)
ideal res_id=fast_map(src_id,currRing,(ideal)theMap,currRing); // FIXME: this dirty hack from original Singular!
std::swap(tmp, theMap->preimage); // map gets its preimage back
assume( tmp == (char*)1 );

res=res_id->m[0];
res_id->m[0]=NULL; idDelete(&res_id);
src_id->m[0]=NULL; idDelete(&src_id);
Expand Down
6 changes: 3 additions & 3 deletions libpolys/polys/monomials/maps.h
Expand Up @@ -8,10 +8,9 @@
*/
#include <coeffs/coeffs.h>
#include <polys/monomials/ring.h>
//#include <kernel/ideals.h>
//#include <polys/simpleideals.h>

struct sip_smap;
typedef struct sip_smap * map;
struct sip_smap; typedef struct sip_smap * map;

// poly maEval(map theMap, poly p, ring dst_ring, nMapFunc nMap, ideal s=NULL);
poly maEval(map theMap, poly p,ring preimage_r,nMapFunc nMap, ideal s, const ring dst_r);
Expand All @@ -29,4 +28,5 @@ ideal idSubstPoly(ideal id, int n, poly e);
poly p_MinPolyNormalize(poly p, const ring r);
int maMaxDeg_P(poly p,ring preimage_r);
int maMaxDeg_Ma(ideal a,ring preimage_r);

#endif
2 changes: 2 additions & 0 deletions libpolys/polys/simpleideals.h
Expand Up @@ -42,6 +42,8 @@ struct sip_smap
int ncols;
};

typedef struct sip_smap * map;

struct sideal_list;
typedef struct sideal_list * ideal_list;

Expand Down

0 comments on commit bf36c43

Please sign in to comment.