Changeset 96f136 in git for Singular/iparith.cc


Ignore:
Timestamp:
Feb 8, 2011, 2:57:14 PM (13 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
771339b035d62cf81e4a3ef0a2b6c35ea5273147
Parents:
06fdbe869e26dea8a81df51c687bbbf427761929
Message:
new command factmodd (Hensel factors in K[[x]][y])

git-svn-id: file:///usr/local/Singular/svn/trunk@13830 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    r06fdbe r96f136  
    78647864};
    78657865#endif
    7866 
     7866static BOOLEAN jjFactModD_M(leftv res, leftv v)
     7867{
     7868  /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
     7869     see doc in /kernel/linearAlgebra.h
     7870     
     7871     valid argument lists:
     7872     - (poly h, int d),
     7873     - (poly h, int d, poly f0, poly g0),       optional: factors of h(0,y),
     7874     - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
     7875                                                          in list of ring vars,
     7876     - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
     7877                                                optional: all 4 optional args
     7878     result:
     7879     - list with the two factors f and g such that
     7880       h(x,y) = f(x,y)*g(x,y) mod x^(d+1)   */
     7881 
     7882  poly h      = NULL;
     7883  int  d      =    1;
     7884  poly f0     = NULL;
     7885  poly g0     = NULL;
     7886  int  xIndex =    1;   /* default index if none provided */
     7887  int  yIndex =    2;   /* default index if none provided */
     7888 
     7889  leftv u = v; int factorsGiven = 0;
     7890  if ((u == NULL) || (u->Typ() != POLY_CMD))
     7891  {
     7892    WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
     7893    return TRUE;
     7894  }
     7895  else h = (poly)u->Data();
     7896  u = u->next;
     7897  if ((u == NULL) || (u->Typ() != INT_CMD))
     7898  {
     7899    WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
     7900    return TRUE;
     7901  }
     7902  else d = (int)(long)u->Data();
     7903  u = u->next;
     7904  if ((u != NULL) && (u->Typ() == POLY_CMD))
     7905  {
     7906    if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
     7907    {
     7908      WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
     7909      return TRUE;
     7910    }
     7911    else
     7912    {
     7913      f0 = (poly)u->Data();
     7914      g0 = (poly)u->next->Data();
     7915      factorsGiven = 1;
     7916      u = u->next->next;
     7917    }
     7918  }
     7919  if ((u != NULL) && (u->Typ() == INT_CMD))
     7920  {
     7921    if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
     7922    {
     7923      WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
     7924      return TRUE;
     7925    }
     7926    else
     7927    {
     7928      xIndex = (int)(long)u->Data();
     7929      yIndex = (int)(long)u->next->Data();
     7930      u = u->next->next;
     7931    }
     7932  }
     7933  if (u != NULL)
     7934  {
     7935    WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
     7936    return TRUE;
     7937  }
     7938 
     7939  /* checks for provided arguments */
     7940  if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
     7941  {
     7942    WerrorS("expected non-constant polynomial argument(s)");
     7943    return TRUE;
     7944  }
     7945  int n = rVar(currRing);
     7946  if ((xIndex < 1) || (n < xIndex))
     7947  {
     7948    Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
     7949    return TRUE;
     7950  }
     7951  if ((yIndex < 1) || (n < yIndex))
     7952  {
     7953    Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
     7954    return TRUE;
     7955  }
     7956  if (xIndex == yIndex)
     7957  {
     7958    WerrorS("expected distinct indices for variables x and y");
     7959    return TRUE;
     7960  }
     7961 
     7962  /* computation of f0 and g0 if missing */
     7963  if (factorsGiven == 0)
     7964  {
     7965#ifdef HAVE_FACTORY
     7966    poly h0 = pSubst(pCopy(h), xIndex, NULL);
     7967    intvec* v = NULL;
     7968    ideal i = singclap_factorize(h0, &v, 0);
     7969    if (i == NULL) return TRUE;
     7970    ivTest(i);
     7971    if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
     7972    {
     7973      WerrorS("expected h(0,y) to have exactly two distinct monic factors");
     7974      return TRUE;
     7975    }
     7976    f0 = pPower(pCopy(i->m[1]), (*v)[1]);
     7977    g0 = pPower(pCopy(i->m[2]), (*v)[2]);
     7978    idDelete(&i);
     7979#else
     7980    WerrorS("cannot factorize h(0,y) due to missing module 'factory'");
     7981    return TRUE;
     7982#endif
     7983  }
     7984 
     7985  poly f; poly g;
     7986  henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
     7987  lists L = (lists)omAllocBin(slists_bin);
     7988  L->Init(2);
     7989  L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
     7990  L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
     7991  res->rtyp = LIST_CMD;
     7992  res->data = (char*)L;
     7993  return FALSE;
     7994}
    78677995static BOOLEAN jjSTATUS_M(leftv res, leftv v)
    78687996{
Note: See TracChangeset for help on using the changeset viewer.