Changeset e63e239 in git


Ignore:
Timestamp:
Jan 19, 2002, 6:11:43 PM (22 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b9020c376e237c88f9dffd14d84ef432f4734b95
Parents:
33293b6db9d4cea6e4dd38872ad570795569fc75
Message:
* extended fast_map function by HAVE_DEST_R


git-svn-id: file:///usr/local/Singular/svn/trunk@5751 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/fast_maps.cc

    r33293b6 re63e239  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 02/01
    9  *  Version: $Id: fast_maps.cc,v 1.15 2002-01-19 16:14:46 Singular Exp $
     9 *  Version: $Id: fast_maps.cc,v 1.16 2002-01-19 17:11:42 obachman Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    1818#include "fast_maps.h"
    1919
     20// define if you want to use special dest_ring
     21#define HAVE_DEST_R 1
     22// define if you want to use special src_ring
     23#define HAVE_SRC_R 0
     24// define if you want to use optimization step
     25#define HAVE_MAP_OPTIMIZATION 0
     26
     27
     28
     29/*******************************************************************************
     30**
     31*F  maMaxExp  . . . . . . . . . . . .  returns maximal exponent of result of map
     32*/
     33// return maximal monomial if max_map_monomials are substituted into pi_m
     34static poly maGetMaxExpP(poly* max_map_monomials,
     35                         int n_max_map_monomials, ring map_r,
     36                         poly pi_m, ring pi_r)
     37{
     38  int n = min(pi_r->N, n_max_map_monomials);
     39  int i, j;
     40  Exponent_t e_i, e_j;
     41  poly m_i, map_j = p_Init(map_r);
     42 
     43  for (i=1; i <= n; i++)
     44  {
     45    e_i = p_GetExp(pi_m, i, pi_r);
     46    m_i = max_map_monomials[i-1];
     47    if (e_i > 0 && m_i != NULL && ! p_IsConstantComp(m_i, map_r))
     48    {
     49      for (j = 1; j<= map_r->N; j++)
     50      {
     51        e_j = p_GetExp(m_i, j, map_r);
     52        if (e_j > 0)
     53        {
     54          p_AddExp(map_j, j, e_j*e_i, map_r);
     55        }
     56      }
     57    }
     58  }
     59  return map_j;
     60}
     61
     62// returns maximal exponent if map_id is applied to pi_id
     63static Exponent_t maGetMaxExp(ideal map_id, ring map_r, ideal pi_id, ring pi_r)
     64{
     65  Exponent_t max=0;
     66  poly* max_map_monomials = (poly*) omAlloc(IDELEMS(map_id)*sizeof(poly));
     67  poly max_pi_i, max_map_i;
     68 
     69  int i, j;
     70  for (i=0; i<IDELEMS(map_id); i++)
     71  {
     72    max_map_monomials[i] = p_GetMaxExpP(map_id->m[i], map_r);
     73  }
     74 
     75  for (i=0; i<IDELEMS(pi_id); i++)
     76  {
     77    max_pi_i = p_GetMaxExpP(pi_id->m[i], pi_r);
     78    max_map_i = maGetMaxExpP(max_map_monomials, IDELEMS(map_id), map_r,
     79                              max_pi_i, pi_r);
     80    Exponent_t temp = p_GetMaxExp(max_map_i, map_r);
     81    if (temp > max){
     82      max=temp;
     83    }
     84
     85    p_LmFree(max_pi_i, pi_r);
     86    p_LmFree(max_map_i, map_r);
     87  }
     88  return max;
     89}
     90
     91
    2092#if 0
    2193// paste into extra.cc
     
    52124
    53125#endif
     126
    54127/*******************************************************************************
    55128**
     
    222295}
    223296
     297
    224298void maMap_CreateRings(ideal map_id, ring map_r,
    225299                       ideal image_id, ring image_r,
    226300                       ring &src_r, ring &dest_r)
    227301{
     302#if HAVE_SRC_R > 0
     303#else
    228304  src_r = map_r;
     305#endif
     306
     307#if HAVE_DEST_R > 0
     308  Exponent_t maxExp = maGetMaxExp(map_id, map_r, image_id, map_r);
     309  dest_r = rModifyRing_Simple(image_r, TRUE, TRUE, maxExp);
     310#else
    229311  dest_r = image_r;
    230 }
    231 
     312#endif
     313}
     314
     315void maMap_KillRings(ring map_r, ring image_r, ring src_r, ring dest_r)
     316{
     317  if (map_r != src_r)
     318    rKillModified_Wp_Ring(src_r);
     319  if (image_r != dest_r)
     320    rKillModifiedRing_Simple(dest_r);
     321}
     322   
    232323ideal maIdeal_2_Ideal(maideal m_id, ring dest_r)
    233324{
     
    247338{
    248339  ring src_r, dest_r;
     340  ideal dest_id, res_id;
     341
     342  // construct rings we work in:
     343  // src_r: Wp with Weights set to length of poly in image_id
     344  // dest_r: Simple ring without degree ordering and short exponents
    249345  maMap_CreateRings(map_id, map_r, image_id, image_r, src_r, dest_r);
    250346 
     347  // construct dest_id
     348  if (dest_r != image_r)
     349    dest_id = idrShallowCopyR(image_id, image_r, dest_r);
     350  else
     351    dest_id = image_id;
     352
     353  // construct mpoly and mideal
    251354  mapoly mp;
    252355  maideal mideal;
    253356  maMap_CreatePolyIdeal(map_id, map_r, src_r, dest_r, mp, mideal);
    254   maPoly_Eval(mp, src_r, image_id, dest_r);
    255 
    256   return maIdeal_2_Ideal(mideal, dest_r);
    257 }
     357 
     358  // do the optimization step
     359#if HAVE_MAP_OPTIMIZE > 0
     360  maPoly_Optimize(mp, src_r);
     361#endif
     362
     363  // do the actual evaluation
     364  maPoly_Eval(mp, src_r, dest_id, dest_r);
     365
     366  // collect the results back into an ideal
     367  ideal res_dest_id = maIdeal_2_Ideal(mideal, dest_r);
     368
     369  // convert result back to image_r
     370  ideal res_image_id;
     371  if (dest_r != image_r)
     372  {
     373    res_image_id = idrShallowCopyR(res_dest_id, dest_r, image_r);
     374    id_ShallowDelete(&res_dest_id, dest_r);
     375  }
     376  else
     377    res_image_id = res_dest_id;
     378 
     379  // clean-up the rings
     380  maMap_KillRings(map_r, image_r, src_r, dest_r);
     381
     382  return res_image_id;
     383}
     384
    258385
    259386#if 0
  • Singular/ring.cc

    r33293b6 re63e239  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.175 2002-01-19 14:48:18 obachman Exp $ */
     4/* $Id: ring.cc,v 1.176 2002-01-19 17:11:42 obachman Exp $ */
    55
    66/*
     
    26572657}
    26582658
     2659// construct lp ring
     2660ring rModifyRing_Simple(ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, int exp_limit)
     2661{
     2662  if (!rHasSimpleOrder(r))
     2663    WarnS("Hannes: you still need to implement this");
     2664  return rModifyRing(r, ommit_degree, ommit_comp, exp_limit);
     2665}
     2666
     2667void rKillModifiedRing_Simple(ring r)
     2668{
     2669  rKillModifiedRing(r);
     2670}
     2671
    26592672 
    26602673void rKillModifiedRing(ring r)
  • Singular/ring.h

    r33293b6 re63e239  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.69 2002-01-19 14:48:19 obachman Exp $ */
     9/* $Id: ring.h,v 1.70 2002-01-19 17:11:43 obachman Exp $ */
    1010
    1111/* includes */
     
    268268void rKillModified_Wp_Ring(ring r);
    269269
     270ring rModifyRing_Simple(ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit);
     271void rKillModifiedRing_Simple(ring r);
     272
    270273void rDebugPrint(ring r);
    271274void pDebugPrint(poly p);
Note: See TracChangeset for help on using the changeset viewer.