Changeset 3be959 in git for Singular


Ignore:
Timestamp:
Feb 26, 2020, 5:15:14 PM (4 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
ec0708752f1b91087c273c68f2c17b842db5a772
Parents:
0d6d56592c854c03d576138fd39bd0808f01ce94
Message:
changed: difform.lib: via global var Omega_R
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/difform.lib

    r0d6d565 r3be959  
    2323    diffAlgebra();                  provides the differential algebra structure and the differential forms dx_1,...,dx_n
    2424    diffAlgebraStructure();         generates the structure of the differential algebra from the basering
    25     diffAlgebraCheck();             checks if the basering already has a differential algebra
    26     diffAlgebraSwitch();            changes the basering to the differential algebra for computations
    2725    diffAlgebraGens();              defines the differential forms dx_1,...,dx_n
    2826    diffAlgebraUnivDerIdeal(ideal); computes the image of an ideal under the universal derivation
     
    7169KEYWORDS: differential forms;differentials;differential algebra
    7270";
    73 ////////////////////////////////////////////////////////////////////////////////////////////////
    74 ////////////////////////////////////////////////////////////////////////////////////////////////
    75 
    76 
    77 ////////////////////////////////////////////////////////////////////////////////////////////////
    78 ////////////////////////////////////////////////////////////////////////////////////////////////
    79 //                                  Initialization of library                                 //
    80 ////////////////////////////////////////////////////////////////////////////////////////////////
    81 ////////////////////////////////////////////////////////////////////////////////////////////////
    82 
     71// Libraries needed
     72LIB "inout.lib";
     73
     74////////////////////////////////////////////////////////////////////////////////
     75//                       Initialization of library                            //
     76////////////////////////////////////////////////////////////////////////////////
    8377
    8478static proc mod_init()
    8579{
    86         // Type of differential forms:
    87         // These are considered as elements (polynomials) in the differential algebra
     80    // Type of differential forms:
     81    // These are considered as elements (polynomials) in the differential algebra
    8882    // NOTE: the polynomials 'form' are not visible in the basering - only in the differential algebra
    89         newstruct("difform","poly form");
     83    newstruct("difform","poly form");
    9084
    9185    // Type of derivations - these are maps: Omega_R^1 -> R
     
    9589    newstruct("derivation","list genIm");
    9690
    97         // Overloads for difform
    98         system("install", "difform", "=", difformFromPoly, 1);
    99         system("install", "difform", "print", difformPrint, 1);
    100 
    101         system("install", "difform", "+", difformAdd, 2);
    102         system("install", "difform", "-", difformSub, 2);
    103         system("install", "difform", "-", difformNeg, 1);
    104         system("install", "difform", "*", difformMul, 2);
     91    // Overloads for difform
     92    system("install", "difform", "=", difformFromPoly, 1);
     93    system("install", "difform", "print", difformPrint, 1);
     94
     95    system("install", "difform", "+", difformAdd, 2);
     96    system("install", "difform", "-", difformSub, 2);
     97    system("install", "difform", "-", difformNeg, 1);
     98    system("install", "difform", "*", difformMul, 2);
    10599    system("install", "difform", "/", difformDiv, 2);
    106         system("install", "difform", "==", difformEqu, 2);
    107         system("install", "difform", "<>", difformNeq, 2);
     100    system("install", "difform", "==", difformEqu, 2);
     101    system("install", "difform", "<>", difformNeq, 2);
    108102    system("install", "difform", ">", difformIsBigger,2);
    109103    system("install", "difform", "<", difformIsSmaller,2);
    110104
    111         system("install", "difform", "deg", difformDeg, 1);
     105    system("install", "difform", "deg", difformDeg, 1);
    112106    system("install", "difform", "homog", difformIsHomog, 1);
    113107
     
    126120    system("install", "derivation", "diff", derivationLie, 2);
    127121
    128     // Libraries needed
    129     LIB "inout.lib";
    130 }
    131 
    132 
    133 ////////////////////////////////////////////////////////////////////////////////////////////////
    134 ////////////////////////////////////////////////////////////////////////////////////////////////
    135 //                            Construction of differential algebra                            //
    136 ////////////////////////////////////////////////////////////////////////////////////////////////
    137 ////////////////////////////////////////////////////////////////////////////////////////////////
     122}
     123
     124
     125////////////////////////////////////////////////////////////////////////////////
     126//                  Construction of differential algebra                      //
     127////////////////////////////////////////////////////////////////////////////////
    138128
    139129
    140130// TODO: check if qringNF option is set - if yes: turn off and set afterwards on
    141131proc diffAlgebra()
    142 "USAGE:         diffAlgebra();
    143 SIDE EFFECTS:   If R is the basering, the differential algebra is constructed with name Omega_R
    144                 and the differential forms dx_1,...,dx_n are available. The name of the differential
    145                 algebra is stored in the attribute attrib(R,"diffAlgebra").
    146 NOTE:           - computations with differential forms need the structure of the differential algebra,
    147                 so this procedure should be executed first.
    148                 - the variable names 'd' or 'D' should be avoided.
    149                 - the procedure also works for quotient rings
    150 KEYWORDS:       differential algebra; differential forms; differentials
    151 SEE ALSO:       diffAlgebraStructure, diffAlgebraGens, diffAlgebraUnivDerIdeal
    152 EXAMPLE:        example diffAlgebra; shows an example"
     132"USAGE:       diffAlgebra();
     133SIDE EFFECTS: If R is the basering, the differential algebra is constructed with name Omega_R
     134              and the differential forms dx_1,...,dx_n are available. The name of the differential
     135              algebra is stored in the attribute attrib(R,"diffAlgebra").
     136NOTE:         - computations with differential forms need the structure of the differential algebra,
     137              so this procedure should be executed first.
     138              - the variable names 'd' or 'D' should be avoided.
     139              - the procedure also works for quotient rings
     140KEYWORDS:     differential algebra; differential forms; differentials
     141SEE ALSO:     diffAlgebraStructure; diffAlgebraGens; diffAlgebraUnivDerIdeal
     142EXAMPLE:      example diffAlgebra; shows an example"
    153143{
    154144
    155145    // Build the differential algebra and store its name as an attribute
    156     string diffAlg_name = diffAlgebraStructure();
    157     attrib(basering,"diffAlgebra",diffAlg_name);
     146    ring Omega_R = diffAlgebraStructure();
     147    attrib(basering,"diffAlgebra","Omega_R");
    158148
    159149    // Construct the differential forms dx_1,...,dx_n over the basering
     
    173163    string info_text = "// The differential algebra " + attrib(basering,"diffAlgebra") + " was constructed and the differential forms " + basic_forms + " are available.";
    174164    print(info_text);
    175     return();
    176 
    177165}
    178166example
     
    200188qring S = std(I);
    201189diffAlgebra();
    202 setring Omega_S;
     190setring Omega_R;
    203191
    204192// The differential algebra is given by:
    205193basering;
    206194
    207 kill Omega_S,dx,dy,dz;
    208 }
    209 
    210 
    211 ////////////////////////////////////////////////////////////////////////////////////////////////
     195kill Omega_R,dx,dy,dz;
     196}
     197
     198
     199////////////////////////////////////////////////////////////////////////////////
    212200
    213201
     
    224212{
    225213
    226     string basering_name = nameof(basering);
    227         list base_list = ringlist(basering);
     214    list base_list = ringlist(basering);
    228215    def R_old = basering;
    229216    ideal quot_ideal = base_list[4];
    230217
    231         // Add Dx_1,...,Dx_n as first variables
    232         list ext_var = base_list[2];
    233         int n = size(ext_var);
    234         int i;
    235 
    236         for(i = 1; i <= n; i++){
    237         ext_var[n+i] = ext_var[i];
    238                 ext_var[i] = "D" + ext_var[n+i];
    239         }
    240 
    241         base_list[2] = ext_var;
     218    // Add Dx_1,...,Dx_n as first variables
     219    list ext_var = base_list[2];
     220    int n = size(ext_var);
     221    int i;
     222
     223    for(i = 1; i <= n; i++)
     224    {
     225      ext_var[n+i] = ext_var[i];
     226      ext_var[i] = "D" + ext_var[n+i];
     227    }
     228
     229    base_list[2] = ext_var;
    242230
    243231    // Preserve the monomial order of the basering
     
    246234    base_list[3] = list(list("dp",weight_vec)) + base_list[3];
    247235
    248         // Add relations x_i*x_j = x_j*x_i and dx_i*dx_j = -dx_j*dx_i
    249         int k = 2*n;
    250         matrix C[k][k];
    251         matrix D[k][k];
    252         int j;
    253 
    254         // Generate strictly upper triangular matrix describing the relations
    255         for(i = 1; i <= k; i++){
    256             for(j = i+1; j <= k ; j++){
    257             if(j <= n){
    258                         C[i,j] = -1;
    259             }else{
    260                 C[i,j] = 1;
    261             }
    262                 }
    263         }
     236    // Add relations x_i*x_j = x_j*x_i and dx_i*dx_j = -dx_j*dx_i
     237    int k = 2*n;
     238    matrix C[k][k];
     239    matrix D[k][k];
     240    int j;
     241
     242    // Generate strictly upper triangular matrix describing the relations
     243    for(i = 1; i <= k; i++)
     244    {
     245      for(j = i+1; j <= k ; j++)
     246      {
     247        if(j <= n)
     248        {
     249          C[i,j] = -1;
     250        }
     251        else
     252        {
     253          C[i,j] = 1;
     254        }
     255      }
     256    }
    264257
    265258    base_list[4] = ideal(0);
    266         base_list[5] = C;
    267         base_list[6] = D;
    268 
    269         // Pass to non-commutative ring with extra variables and relations
    270         ring R_intermediate = ring(base_list);
    271 
    272         // Add relations Dx_i*Dx_i = 0 via generating a quotient ring
    273         ideal REL;
    274         for(i = 1; i <= n; i++){
    275                 REL[i] = var(i)*var(i);
    276         }
    277 
    278         // Build the differential algebra for the polynomial ring - the free module
     259    base_list[5] = C;
     260    base_list[6] = D;
     261
     262    // Pass to non-commutative ring with extra variables and relations
     263    ring R_intermediate = ring(base_list);
     264
     265    // Add relations Dx_i*Dx_i = 0 via generating a quotient ring
     266    ideal REL;
     267    for(i = 1; i <= n; i++)
     268    {
     269      REL[i] = var(i)*var(i);
     270    }
     271
     272    // Build the differential algebra for the polynomial ring - the free module
    279273    qring diffAlg_poly = twostd(REL);
    280274
     
    282276    ideal quot_ideal = imap(R_old,quot_ideal);
    283277
    284     if(quot_ideal != 0){
    285 
    286         // Compute the universal derivation of the generators of the ideal
    287         quot_ideal = quot_ideal + diffAlgebraUnivDerIdeal(quot_ideal);
    288 
    289         // Add the additional relations, generate the differential algebra with name Omega_R and export it
    290         string diffAlg_name = "Omega_" + basering_name;
    291             execute("qring " + diffAlg_name + " = twostd(quot_ideal);");
    292         execute("exportto(Top," + diffAlg_name + ");");
    293 
    294         return(diffAlg_name);
     278    if(size(quot_ideal) != 0)
     279    {
     280      // Compute the universal derivation of the generators of the ideal
     281      quot_ideal = quot_ideal + diffAlgebraUnivDerIdeal(quot_ideal);
     282
     283      // Add the additional relations, generate the differential algebra with name Omega_R and export it
     284      qring Omega_R = twostd(quot_ideal);
     285      exportto(Top,Omega_R);
     286
     287      return(Omega_R);
    295288    }
    296289
    297290    // Give the differential algebra the name Omega_basering and export it
    298     string diffAlg_name = "Omega_" + basering_name;
    299         execute("ring " + diffAlg_name + " = diffAlg_poly;");
    300     execute("exportto(Top," + diffAlg_name + ");");
    301 
    302     return(diffAlg_name);
    303 
    304 }
    305 
    306 
    307 ////////////////////////////////////////////////////////////////////////////////////////////////
    308 
    309 
    310 proc diffAlgebraCheck()
    311 "USAGE:         diffAlgebraCheck();
    312 SIDE EFFECTS:   Checks if the basering has a differential algebra and aborts with an error if this is not the case
    313 REMARKS:        The procedure checks if the name in the attribute attrib(basering,"diffAlgebra") is not empty. This
    314                 is the case if the procedure diffAlgebra was executed first.
    315 NOTE:           whenever computations with differential forms are done, it should be checked if the differential
    316                 algebra was already generated since differential forms are polynomials in the differential algebra
    317 KEYWORDS:       differential algebra
    318 SEE ALSO:       diffAlgebraSwitch"
    319 {
    320     string diffAlg_name = attrib(basering,"diffAlgebra");
    321     if(size(diffAlg_name) == 0){
    322         ERROR("Ring does not have a differential algebra!");
    323     }
    324 }
    325 
    326 
    327 ////////////////////////////////////////////////////////////////////////////////////////////////
    328 
    329 
    330 proc diffAlgebraSwitch()
    331 "USAGE:         diffAlgebraSwitch();
    332 ASSUME:         The differential algebra was already constructed.
    333 SIDE EFFECTS:   Changes the ring: from the basering to the differential algebra.
    334 NOTE:           whenever computations with differential forms are done, the ring must be changed to the differential
    335                 algebra since differential forms are polynomials there. But first it should be checked if the algebra
    336                 is actually available: so before executing diffAlgebraSwitch there should always be an preceding diffAlgebraCheck
    337 KEYWORDS:       differential algebra
    338 SEE ALSO:       diffAlgebraCheck"
    339 {
    340 
    341     string diffAlg_name = attrib(basering,"diffAlgebra");
    342     execute("setring " + diffAlg_name);
    343     execute("keepring " + diffAlg_name);
    344 
    345 }
    346 
    347 
    348 ////////////////////////////////////////////////////////////////////////////////////////////////
     291    ring Omega_R = diffAlg_poly;
     292    exportto(Top,Omega_R);
     293
     294    return(Omega_R);
     295}
     296
     297
     298////////////////////////////////////////////////////////////////////////////////
     299
     300
     301////////////////////////////////////////////////////////////////////////////////
     302
     303
     304////////////////////////////////////////////////////////////////////////////////
    349305
    350306
     
    356312{
    357313
    358     diffAlgebraSwitch();
    359 
    360     list ext_var = ringlist(basering)[2];
     314    setring Omega_R;
     315
     316    list ext_var = ringlist(Omega_R)[2];
    361317    int n = size(ext_var) div 2;
    362318    int i;
     
    391347    ideal d_I;
    392348
    393     for(j = 1; j <= k; j++){
     349    for(j = 1; j <= k; j++)
     350    {
    394351        d_I[j] = 0;
    395         for(i = 1; i <= n; i++){
     352        for(i = 1; i <= n; i++)
     353        {
    396354            d_I[j] = d_I[j] + diff(I[j],var(i+n))*var(i);
    397355        }
    398356    }
    399 
    400357    return(d_I);
    401358
     
    435392
    436393    // Get information from input
    437     for(i = 1; i <= n; i++){
    438         if(typeof(#[i]) == "string"){
    439 
    440             if(#[i] == "gen" && typeof(#[i+1]) == "string"){
     394    for(i = 1; i <= n; i++)
     395    {
     396        if(typeof(#[i]) == "string")
     397        {
     398            if(#[i] == "gen" && typeof(#[i+1]) == "string")
     399            {
    441400                gen_ord = #[i+1];
    442                 if(typeof(#[i+2]) == "intvec"){
     401                if(typeof(#[i+2]) == "intvec")
     402                {
    443403                    intvec gen_weight = #[i+2];
    444404                }
    445405            }
    446 
    447             if(#[i] == "ringvar" && typeof(#[i+1]) == "string"){
     406            if(#[i] == "ringvar" && typeof(#[i+1]) == "string")
     407            {
    448408                ringvar_ord = #[i+1];
    449                 if(typeof(#[i+2]) == "intvec"){
     409                if(typeof(#[i+2]) == "intvec")
     410                {
    450411                    intvec ringvar_weight = #[i+2];
    451412                }
     
    456417    // Check input for consistency
    457418    // Generator ordering must be a valid monomial ordering
    458     if(gen_ord != "" && gen_ord != "lp" && gen_ord != "rp" && gen_ord != "dp" && gen_ord != "Dp" && gen_ord != "wp" && gen_ord != "Wp"){
    459         if(gen_ord != "ls" && gen_ord != "ds" && gen_ord != "Ds" && gen_ord != "ws" && gen_ord != "Ws"){
     419    if(gen_ord != "" && gen_ord != "lp" && gen_ord != "rp" && gen_ord != "dp" && gen_ord != "Dp" && gen_ord != "wp" && gen_ord != "Wp")
     420    {
     421        if(gen_ord != "ls" && gen_ord != "ds" && gen_ord != "Ds" && gen_ord != "ws" && gen_ord != "Ws")
     422        {
    460423            ERROR("Not a valid ordering!");
    461424        }
    462425    }
    463 
    464426    // Ringvariable ordering must be a valid monomial ordering
    465     if(ringvar_ord != "" && ringvar_ord != "lp" && ringvar_ord != "rp" && ringvar_ord != "dp" && ringvar_ord != "Dp" && ringvar_ord != "wp" && ringvar_ord != "Wp"){
    466         if(ringvar_ord != "ls" && ringvar_ord != "ds" && ringvar_ord != "Ds" && ringvar_ord != "ws" && ringvar_ord != "Ws"){
     427    if(ringvar_ord != "" && ringvar_ord != "lp" && ringvar_ord != "rp" && ringvar_ord != "dp" && ringvar_ord != "Dp" && ringvar_ord != "wp" && ringvar_ord != "Wp")
     428    {
     429        if(ringvar_ord != "ls" && ringvar_ord != "ds" && ringvar_ord != "Ds" && ringvar_ord != "ws" && ringvar_ord != "Ws")
     430        {
    467431            ERROR("Not a valid ordering!");
    468432        }
    469433    }
    470 
    471434    // If the generator ordering is a weighted monomial ordering, a weight-vector is needed
    472     if(gen_ord == "wp" || gen_ord == "Wp" || gen_ord == "ws" || gen_ord == "Ws"){
    473         if(!defined(gen_weight)){
     435    if(gen_ord == "wp" || gen_ord == "Wp" || gen_ord == "ws" || gen_ord == "Ws")
     436    {
     437        if(!defined(gen_weight))
     438        {
    474439            ERROR("No weight vector given!");
    475440        }
    476 
    477         if(size(gen_weight) != k){
     441        if(size(gen_weight) != k)
     442        {
    478443            ERROR("Weight vector has wrong size!");
    479444        }
    480     }else{
     445    }
     446    else
     447    {
    481448    // If a weight vector is given although the monomial ordering is not weighted
    482         if(defined(gen_weight)){
     449        if(defined(gen_weight))
     450        {
    483451            kill gen_weight;
    484452        }
    485453    }
    486 
    487454    // If the ordering for the ring variables is a weighted monmial ordering, a weight-vector is needed
    488     if(ringvar_ord == "wp" || ringvar_ord == "Wp" || ringvar_ord == "ws" || ringvar_ord == "Ws"){
    489         if(!defined(ringvar_weight)){
     455    if(ringvar_ord == "wp" || ringvar_ord == "Wp" || ringvar_ord == "ws" || ringvar_ord == "Ws")
     456    {
     457        if(!defined(ringvar_weight))
     458        {
    490459            ERROR("No weight vector given!");
    491460        }
    492 
    493         if(size(ringvar_weight) != k){
     461        if(size(ringvar_weight) != k)
     462        {
    494463            ERROR("Weight vector has wrong size!");
    495464        }
    496     }else{
     465    }
     466    else
     467    {
    497468    // If a weight vector is given although the monomial ordering is not weighted
    498         if(defined(ringvar_weight)){
     469        if(defined(ringvar_weight))
     470        {
    499471            kill ringvar_weight;
    500472        }
    501473    }
    502 
    503474    list L_diff_Alg = ringlist(basering);
    504475    n = size(L_diff_Alg[3]);
    505476
    506477    // Change ordering of generators
    507     if(gen_ord != ""){
     478    if(gen_ord != "")
     479    {
    508480        L_diff_Alg[3][1][1] = gen_ord;
    509         if(defined(gen_weight)){
     481        if(defined(gen_weight))
     482        {
    510483            L_diff_Alg[3][1][2] = gen_weight;
    511484        }
     
    513486
    514487    // Change the ordering of the ringvariables
    515     if(ringvar_ord != ""){
     488    if(ringvar_ord != "")
     489    {
    516490        list L;
    517491        L[1] = L_diff_Alg[3][1];
    518 
    519492        L[2] = list();
    520493        L[2][1] = ringvar_ord;
    521         if(defined(ringvar_weight)){
     494        if(defined(ringvar_weight))
     495        {
    522496            L[2][2] = ringvar_weight;
    523         }else{
     497        }
     498        else
     499        {
    524500            L[2][2] = 1:k;
    525501        }
    526 
    527502        L_diff_Alg[3] = L;
    528503    }
     
    530505    def T = ring(L_diff_Alg);
    531506    return(T);
    532 
    533507}
    534508
     
    539513proc diffAlgebraListGen(list #)
    540514"USAGE: diffAlgebraListGen(#); # list
    541 RETURN:     - a list of generetors of the differential algebra as module over the basering
     515RETURN:     - a list of generators of the differential algebra as module over the basering
    542516            - a list of generators of a graded part of the differential algebra
    543517REMARKS:    In order to find all generators, they are counted 'binary': The generators are in
     
    552526EXAMPLE:    example diffAlgebraListGen; shows an example"
    553527{
    554 
    555     diffAlgebraCheck();
    556 
    557528    int n = size(ringlist(basering)[2]);
    558529    int i,k,j;
     
    564535
    565536    // Get optional degree
    566     if(size(#) > 0){
    567         if(typeof(#[1]) == "int"){
     537    if(size(#) > 0)
     538    {
     539        if(typeof(#[1]) == "int")
     540        {
    568541            degr = #[1];
    569542        }
     
    572545    // Build the list of all dx_i
    573546    def R_old = basering;
    574     diffAlgebraSwitch();
    575 
    576     for(i = 1; i <= n; i++){
     547    setring Omega_R;
     548
     549    for(i = 1; i <= n; i++)
     550    {
    577551        current_var.form = var(i);
    578552        var_list[i] = current_var;
     
    583557    // Find all generators (of given degree)
    584558    list dual_i;
    585     for(i = 1; i < 2^n; i++){
     559    for(i = 1; i < 2^n; i++)
     560    {
    586561        // Compute dual number representation
    587562        dual_i = diffAlgebraIntToDual(i);
     
    590565
    591566        // Convert dual number to generator
    592         for(j = 1; j <= k; j++){
    593             if(dual_i[j] != 0){
     567        for(j = 1; j <= k; j++)
     568        {
     569            if(dual_i[j] != 0)
     570            {
    594571                current_gen = current_gen*var_list[j];
    595572            }
     
    597574
    598575        // Add generator if it has the given degree or degree was not chosen
    599         if(degr == -1 || difformDeg(current_gen) == degr){
     576        if(degr == -1 || difformDeg(current_gen) == degr)
     577        {
    600578            GEN_list = GEN_list + list(current_gen);
    601579        }
     
    603581
    604582    // Add generator 1
    605     if(degr == 0 || degr == -1){
     583    if(degr == 0 || degr == -1)
     584    {
    606585        difform gen_one = 1;
    607586        GEN_list = list(gen_one) + GEN_list;
     
    609588
    610589    return(difformListSort(GEN_list));
    611 
    612590}
    613591example
     
    631609
    632610
    633 ////////////////////////////////////////////////////////////////////////////////////////////////
     611////////////////////////////////////////////////////////////////////////////////
    634612
    635613
     
    641619SEE ALSO:   diffAlgebraListGen"
    642620{
    643 
    644621    list dual_number;
    645622
    646     while(l div 2 != 0){
     623    while(l div 2 != 0)
     624    {
    647625        dual_number = dual_number + list(l mod 2);
    648626        l = l div 2;
    649627    }
    650 
    651628    dual_number = dual_number + list(l mod 2);
    652 
    653629    return(dual_number);
    654 
    655 }
    656 
    657 
    658 ////////////////////////////////////////////////////////////////////////////////////////////////
    659 ////////////////////////////////////////////////////////////////////////////////////////////////
    660 //                                Procedures for type difform                                 //
    661 ////////////////////////////////////////////////////////////////////////////////////////////////
    662 ////////////////////////////////////////////////////////////////////////////////////////////////
    663 
    664 
    665 ////////////////////////////////////////////////////////////////////////////////////////////////
    666 //----------------------------------- Structural procedures ----------------------------------//
    667 ////////////////////////////////////////////////////////////////////////////////////////////////
     630}
     631
     632
     633////////////////////////////////////////////////////////////////////////////////
     634////////////////////////////////////////////////////////////////////////////////
     635//                     Procedures for type difform                            //
     636////////////////////////////////////////////////////////////////////////////////
     637////////////////////////////////////////////////////////////////////////////////
     638
     639
     640////////////////////////////////////////////////////////////////////////////////
     641//----------------------- Structural procedures ------------------------------//
     642////////////////////////////////////////////////////////////////////////////////
    668643
    669644
     
    677652{
    678653
    679     diffAlgebraCheck();
    680654    def R_old = basering;
    681     diffAlgebraSwitch();
     655    setring Omega_R;
    682656
    683657    poly g = imap(R_old,f);
     
    686660
    687661    return(df);
    688 
    689662}
    690663example
     
    712685
    713686
    714 ////////////////////////////////////////////////////////////////////////////////////////////////
     687////////////////////////////////////////////////////////////////////////////////
    715688
    716689
     
    726699EXAMPLE:    example difformCoef; shows an example"
    727700{
    728 
    729     diffAlgebraCheck();
    730701    def R_old = basering;
    731     diffAlgebraSwitch();
     702    setring Omega_R;
    732703    def diff_Alg = basering;
    733704
     
    736707    int i;
    737708
    738         // Build the wedge product of all differential forms dx_i
    739         poly wedge_mon = 1;
    740         for(i = 1; i <= n; i++){
    741                 wedge_mon = wedge_mon*var(i);
    742         }
    743 
    744         // Find the coefficients of the generators
     709    // Build the wedge product of all differential forms dx_i
     710    poly wedge_mon = 1;
     711    for(i = 1; i <= n; i++)
     712    {
     713      wedge_mon = wedge_mon*var(i);
     714    }
     715
     716    // Find the coefficients of the generators
    745717    matrix df_coefs = coef(f,wedge_mon);
    746718    int k = ncols(df_coefs);
     
    753725    list repr;
    754726
    755     for(i = 1;i <= k;i++){
    756         repr[i] = list();
    757         setring diff_Alg;
    758 
    759         // Generators as differential forms
    760         current_gen.form = df_coefs[1,i];
    761 
    762         // Coefficients are polynomials in the basering
    763         coeff_above = df_coefs[2,i];
    764         setring R_old;
    765         coeff = imap(diff_Alg,coeff_above);
    766 
    767         repr[i][1] = current_gen;
    768         repr[i][2] = coeff;
     727    for(i = 1;i <= k;i++)
     728    {
     729      repr[i] = list();
     730      setring diff_Alg;
     731
     732      // Generators as differential forms
     733      current_gen.form = df_coefs[1,i];
     734
     735      // Coefficients are polynomials in the basering
     736      coeff_above = df_coefs[2,i];
     737      setring R_old;
     738      coeff = imap(diff_Alg,coeff_above);
     739
     740      repr[i][1] = current_gen;
     741      repr[i][2] = coeff;
    769742    }
    770743
    771744    // Return representation
    772745    return(repr);
    773 
    774746}
    775747example
     
    797769
    798770
    799 ////////////////////////////////////////////////////////////////////////////////////////////////
     771////////////////////////////////////////////////////////////////////////////////
    800772
    801773
     
    809781SEE ALSO:   difformToString"
    810782{
    811 
    812     diffAlgebraSwitch();
     783    setring Omega_R;
    813784    string df_out_un = string(df.form);
    814     list vars_ = ringlist(basering)[2];
     785    list vars_ = ringlist(Omega_R)[2];
    815786    int n = size(vars_) div 2;
    816787    int i,j;
    817788
    818789    // Replace the Dx_i in the string with the dx_i
    819     for(i = 1; i <= n; i++){
     790    for(i = 1; i <= n; i++)
     791    {
    820792        j = find(df_out_un,string(vars_[i]));
    821793
    822         while(j!=0){
     794        while(j!=0)
     795        {
    823796            df_out_un[j] = "d";
    824797            j = find(df_out_un,vars_[i]);
    825798        }
    826799    }
    827 
    828800    return(df_out_un);
    829 
    830 }
    831 
    832 
    833 ////////////////////////////////////////////////////////////////////////////////////////////////
    834 
     801}
     802
     803////////////////////////////////////////////////////////////////////////////////
    835804
    836805// TODO: check optionIsSet("qringNF") - ADD ring.lib !!! and reduce by hand
     
    848817EXAMPLE:    example difformToString; shows an example"
    849818{
    850 
    851819    // Get the coefficients
    852820    list repr = difformCoef(df);
     
    857825    int i;
    858826
    859     for(i = 1; i <= n; i++){
    860         if(typeof(#[i]) == "string"){
    861             if(#[i] == "gen" && typeof(#[i+1]) == "string"){
     827    for(i = 1; i <= n; i++)
     828    {
     829        if(typeof(#[i]) == "string")
     830        {
     831            if(#[i] == "gen" && typeof(#[i+1]) == "string")
     832            {
    862833                gen_ord = #[i+1];
    863                 if(typeof(#[i+2]) == "intvec"){
     834                if(typeof(#[i+2]) == "intvec")
     835                {
    864836                    intvec gen_weight = #[i+2];
    865837                }
     
    869841
    870842    // Sort the generator/coefficients by the chosen ordering
    871     if(gen_ord != ""){
    872         if(defined(gen_weight)){
     843    if(gen_ord != "")
     844    {
     845        if(defined(gen_weight))
     846        {
    873847            repr = difformListSort(repr,"Llist","gen",gen_ord,gen_weight);
    874         }else{
     848        }
     849        else
     850        {
    875851            repr = difformListSort(repr,"Llist","gen",gen_ord);
    876852        }
    877     }else{
     853    }
     854    else
     855    {
    878856        repr = difformListSort(repr,"Llist");
    879857    }
     
    888866    string df_coef_str;
    889867
    890     for(i = n; i >= 1; i--){
     868    for(i = n; i >= 1; i--)
     869    {
    891870        df_gen = repr[i][1];
    892871        df_gen_str = difformGenToString(df_gen);
     
    895874
    896875        // Check the coefficients and generators
    897         while(1){
     876        while(1)
     877        {
    898878            // Special cases without brackets:
    899879
     
    912892
    913893        // Add a plus sign
    914         if(i > 1){
     894        if(i > 1)
     895        {
    915896            df_out = df_out + "+";
    916897        }
    917898    }
    918899
    919         return(df_out);
    920 
     900    return(df_out);
    921901}
    922902example
     
    955935EXAMPLE:        example difformPrint; shows an example"
    956936{
    957 
    958937    // Print in ds-order on the generators
    959         print(difformToString(df,"gen","ds"));
    960     return();
    961 
     938    print(difformToString(df,"gen","ds"));
    962939}
    963940example
     
    990967"
    991968{
    992 
    993     diffAlgebraCheck();
    994969    list df_gen_repr = difformCoef(df);
    995970    int n = size(df_gen_repr);
    996971
    997     if(n == 1 && df_gen_repr[1][2] == 1){
     972    if(n == 1 && df_gen_repr[1][2] == 1)
     973    {
    998974        return(1);
    999975    }
    1000 
    1001976    return(0);
    1002 
    1003977}
    1004978example
     
    10431017EXAMPLE:    example difformAdd; shows an example"
    10441018{
    1045 
    1046     diffAlgebraCheck();
    1047     diffAlgebraSwitch();
     1019    setring Omega_R;
    10481020
    10491021    difform dsum;
     
    10891061EXAMPLE:    example difformSub; shows an example"
    10901062{
    1091 
    1092         diffAlgebraCheck();
    1093     diffAlgebraSwitch();
     1063    setring Omega_R;
    10941064
    10951065    difform dsub;
     
    10981068
    10991069    return(dsub);
    1100 
    11011070}
    11021071example
     
    11351104EXAMPLE:    example difformNeg; shows an example"
    11361105{
    1137 
    1138         diffAlgebraCheck();
    1139     diffAlgebraSwitch();
     1106    setring Omega_R;
    11401107
    11411108    difform dneg;
     
    11441111
    11451112    return(dneg);
    1146 
    11471113}
    11481114example
     
    11631129
    11641130
    1165 ////////////////////////////////////////////////////////////////////////////////////////////////
     1131////////////////////////////////////////////////////////////////////////////////
    11661132
    11671133
     
    11731139EXAMPLE:    example difformMul; shows an example"
    11741140{
    1175 
    1176         diffAlgebraCheck();
    1177     diffAlgebraSwitch();
     1141    setring Omega_R;
    11781142
    11791143    difform dmul;
     
    11821146
    11831147    return(dmul);
    1184 
    11851148}
    11861149example
     
    12191182EXAMPLE:    example difformDiv; shows an example"
    12201183{
    1221 
    1222     diffAlgebraCheck();
    1223     diffAlgebraSwitch();
     1184    setring Omega_R;
    12241185
    12251186    difform ddiv;
     
    12281189
    12291190    return(ddiv);
    1230 
    12311191}
    12321192example
     
    12551215
    12561216
    1257 ////////////////////////////////////////////////////////////////////////////////////////////////
     1217////////////////////////////////////////////////////////////////////////////////
    12581218
    12591219
     
    12651225EXAMPLE:    example difformEqu; shows an example"
    12661226{
    1267 
    1268         diffAlgebraCheck();
    1269     diffAlgebraSwitch();
    1270 
     1227    setring Omega_R;
    12711228    return(df.form == dg.form);
    1272 
    12731229}
    12741230example
     
    12931249
    12941250
    1295 ////////////////////////////////////////////////////////////////////////////////////////////////
     1251////////////////////////////////////////////////////////////////////////////////
    12961252
    12971253
     
    13031259EXAMPLE:    example difformNeq; shows an example"
    13041260{
    1305 
    13061261        return(!difformEqu(df,dg));
    1307 
    13081262}
    13091263example
     
    13471301EXAMPLE:    example difformIsBigger; shows an example"
    13481302{
    1349 
    1350     diffAlgebraCheck();
    1351     diffAlgebraSwitch();
     1303    setring Omega_R;
    13521304
    13531305    poly df_form = df.form;
    13541306    poly dg_form = dg.form;
    13551307
    1356     if(size(#) > 0){
    1357         def diff_Alg = basering;
     1308    if(size(#) > 0)
     1309    {
     1310        def diff_Alg = Omega_R;
    13581311        ring T = diffAlgebraChangeOrd(#);
    13591312
     
    13641317
    13651318    return(df_form > dg_form);
    1366 
    13671319}
    13681320example
     
    13921344
    13931345
    1394 ////////////////////////////////////////////////////////////////////////////////////////////////
     1346////////////////////////////////////////////////////////////////////////////////
    13951347
    13961348
     
    14111363EXAMPLE:    example difformIsSmaller; shows an example"
    14121364{
    1413 
    1414     diffAlgebraCheck();
    1415     diffAlgebraSwitch();
     1365    setring Omega_R;
    14161366
    14171367    poly df_form = df.form;
    14181368    poly dg_form = dg.form;
    14191369
    1420     if(size(#) > 0){
     1370    if(size(#) > 0)
     1371    {
    14211372        def diff_Alg = basering;
    14221373        ring T = diffAlgebraChangeOrd(#);
     
    14261377        return(df_form_T < dg_form_T);
    14271378    }
    1428 
    14291379    return(df.form < dg.form);
    1430 
    14311380}
    14321381example
     
    14561405
    14571406
    1458 ////////////////////////////////////////////////////////////////////////////////////////////////
    1459 //------------------------- Procedures for computing with the degree -------------------------//
    1460 ////////////////////////////////////////////////////////////////////////////////////////////////
     1407////////////////////////////////////////////////////////////////////////////////
     1408//------------ Procedures for computing with the degree ----------------------//
     1409////////////////////////////////////////////////////////////////////////////////
    14611410
    14621411
     
    14711420EXAMPLE:    example difformDeg; shows an example"
    14721421{
    1473 
    1474     diffAlgebraCheck();
    1475     diffAlgebraSwitch();
     1422    setring Omega_R;
    14761423
    14771424    // Degree of a difform is the degree of the poly with weights 0 for the basering variables
    1478     int n = size(ringlist(basering)[2]) div 2;
     1425    int n = size(ringlist(Omega_R)[2]) div 2;
    14791426    int i;
    14801427    intvec var_weights;
    14811428
    1482     for(i = 1; i <= n; i++){
     1429    for(i = 1; i <= n; i++)
     1430    {
    14831431        var_weights[i] = 1;
    14841432        var_weights[i+n] = 0;
    14851433    }
    1486 
    14871434    return(deg(df.form,var_weights));
    1488 
    14891435}
    14901436example
     
    15111457}
    15121458
    1513 
    1514 ////////////////////////////////////////////////////////////////////////////////////////////////
     1459////////////////////////////////////////////////////////////////////////////////
    15151460
    15161461
     
    15251470EXAMPLE:    example difformIsHomog; shows an example"
    15261471{
    1527 
    1528         diffAlgebraCheck();
    1529     diffAlgebraSwitch();
    1530 
    1531     int n = size(ringlist(basering)[2]) div 2;
     1472    setring Omega_R;
     1473
     1474    int n = size(ringlist(Omega_R)[2]) div 2;
    15321475    int i;
    15331476    intvec var_weights;
    15341477
    1535     for(i = 1; i <= n; i++){
     1478    for(i = 1; i <= n; i++)
     1479    {
    15361480        var_weights[i] = 1;
    15371481        var_weights[i+n] = 0;
    15381482    }
    1539 
    15401483    return(homog(df.form,var_weights));
    1541 
    15421484}
    15431485example
     
    15721514
    15731515
    1574 ////////////////////////////////////////////////////////////////////////////////////////////////
     1516////////////////////////////////////////////////////////////////////////////////
    15751517
    15761518
     
    15831525EXAMPLE:    example difformIsHomogDeg; shows an example"
    15841526{
    1585 
    15861527        int df_deg = difformDeg(df);
    15871528        int is_hom = difformIsHomog(df);
    15881529        return(df_deg == p && is_hom == 1);
    1589 
    15901530}
    15911531example
     
    16201560
    16211561
    1622 ////////////////////////////////////////////////////////////////////////////////////////////////
     1562////////////////////////////////////////////////////////////////////////////////
    16231563
    16241564
     
    16321572EXAMPLE:    example difformHomogDecomp; shows an example"
    16331573{
    1634 
    1635     diffAlgebraCheck();
    1636 
    16371574    // Highest degree is the nr. of variables in the basering
    16381575    int n = size(ringlist(basering)[2]);
     
    16431580
    16441581    // Generate a list full of 0s
    1645     for(i = 1;i <= (n+1); i++){
     1582    for(i = 1;i <= (n+1); i++)
     1583    {
    16461584        homog_part[i] = 0;
    16471585    }
     
    16521590
    16531591    // Sort in list
    1654     for(i = 1; i <= k; i++){
     1592    for(i = 1; i <= k; i++)
     1593    {
    16551594        current_gen = df_gen_repr[i][1];
    16561595        current_coef = df_gen_repr[i][2];
    16571596        j = difformDeg(current_gen);
    16581597
    1659         if(j == 0){
     1598        if(j == 0)
     1599        {
    16601600            homog_part[n+1] = homog_part[n+1] + current_coef*current_gen;
    1661         }else{
     1601        }
     1602        else
     1603        {
    16621604            homog_part[j] = homog_part[j] + current_coef*current_gen;
    16631605        }
    16641606    }
    1665 
    16661607    return(homog_part);
    1667 
    16681608}
    16691609example
     
    16861626
    16871627
    1688 ////////////////////////////////////////////////////////////////////////////////////////////////
    1689 //------------------------ Procedures for lists of differential forms ------------------------//
    1690 ////////////////////////////////////////////////////////////////////////////////////////////////
     1628////////////////////////////////////////////////////////////////////////////////
     1629//--------------- Procedures for lists of differential forms -----------------//
     1630////////////////////////////////////////////////////////////////////////////////
    16911631
    16921632
     
    16991639EXAMPLE:    example difformListCont; shows an example"
    17001640{
    1701 
    1702     diffAlgebraCheck();
    1703 
    17041641    int n = size(L);
    17051642    int i;
    17061643
    1707     for(i = 1; i <= n; i++){
    1708         if(typeof(L[i]) == "difform"){
    1709             if(difformEqu(df,L[i])){
     1644    for(i = 1; i <= n; i++)
     1645    {
     1646        if(typeof(L[i]) == "difform")
     1647        {
     1648            if(difformEqu(df,L[i]))
     1649            {
    17101650                return(1);
    17111651            }
    17121652        }
    17131653    }
    1714 
    17151654    return(0);
    1716 
    17171655}
    17181656example
     
    17421680
    17431681
    1744 ////////////////////////////////////////////////////////////////////////////////////////////////
     1682////////////////////////////////////////////////////////////////////////////////
    17451683
    17461684
     
    17681706EXAMPLE:    example difformListSort; shows an example"
    17691707{
    1770 
    1771     diffAlgebraCheck();
    1772 
    17731708    list orderings = #;
    17741709    int n = size(orderings);
     
    17781713
    17791714    // Check for double list
    1780     for(i = 1; i <= n; i++){
    1781         if(typeof(orderings[i]) == "string"){
    1782             if(orderings[i] == "Dlist"){
     1715    for(i = 1; i <= n; i++)
     1716    {
     1717        if(typeof(orderings[i]) == "string")
     1718        {
     1719            if(orderings[i] == "Dlist")
     1720            {
    17831721                Dlist_flag = 1;
    17841722                orderings = delete(orderings,i);
     
    17881726
    17891727    // Check for list of lists
    1790     for(i = 1; i <= n; i++){
    1791         if(typeof(orderings[i]) == "string"){
    1792             if(orderings[i] == "Llist"){
     1728    for(i = 1; i <= n; i++)
     1729    {
     1730        if(typeof(orderings[i]) == "string")
     1731        {
     1732            if(orderings[i] == "Llist")
     1733            {
    17931734                Llist_flag = 1;
    17941735                orderings = delete(orderings,i);
     
    17981739
    17991740    // Not both list forms allowed
    1800     if(Dlist_flag == 1 && Llist_flag == 1){
     1741    if(Dlist_flag == 1 && Llist_flag == 1)
     1742    {
    18011743        ERROR("Cannot sort double list of lists!");
    18021744    }
    18031745
    18041746    // Double list detected
    1805     if(Dlist_flag == 1){
     1747    if(Dlist_flag == 1)
     1748    {
    18061749        poly temp_form_sec;
    18071750        list L_sec = L[2];
     
    18101753
    18111754    // List of lists detected
    1812     if(Llist_flag == 1){
     1755    if(Llist_flag == 1)
     1756    {
    18131757        poly temp_form_sec;
    18141758        n = size(L);
     
    18171761
    18181762        // Transform list of lists to double list
    1819         for(i = 1; i <= n; i++){
     1763        for(i = 1; i <= n; i++)
     1764        {
    18201765            L_temp[i] = L[i][1];
    18211766            L_sec[i] = L[i][2];
     
    18291774    n = size(L);
    18301775
    1831     for(i = 1; i <= n; i++){
     1776    for(i = 1; i <= n; i++)
     1777    {
    18321778        temp_form = L[i];
    18331779
    1834         if(Dlist_flag == 1 || Llist_flag == 1){
     1780        if(Dlist_flag == 1 || Llist_flag == 1)
     1781        {
    18351782            temp_form_sec = L_sec[i];
    18361783        }
     
    18381785        j = i;
    18391786
    1840         while(j > 1){
    1841             if(difformIsBigger(L[j-1],temp_form,orderings)){
     1787        while(j > 1)
     1788        {
     1789            if(difformIsBigger(L[j-1],temp_form,orderings))
     1790            {
    18421791                L[j] = L[j-1];
    18431792
    1844                 if(Dlist_flag == 1 || Llist_flag == 1){
     1793                if(Dlist_flag == 1 || Llist_flag == 1)
     1794                {
    18451795                    L_sec[j] = L_sec[j-1];
    18461796                }
    18471797
    18481798                j--;
    1849             }else{
     1799            }
     1800            else
     1801            {
    18501802                break;
    18511803            }
     
    18541806        L[j] = temp_form;
    18551807
    1856         if(Dlist_flag == 1 || Llist_flag == 1){
     1808        if(Dlist_flag == 1 || Llist_flag == 1)
     1809        {
    18571810            L_sec[j] = temp_form_sec;
    18581811        }
     
    18601813
    18611814    // For double list - return a double list
    1862     if(Dlist_flag == 1){
     1815    if(Dlist_flag == 1)
     1816    {
    18631817        return(list(L,L_sec));
    18641818    }
    18651819
    18661820    // For list of lists - return a list of lists
    1867     if(Llist_flag == 1){
     1821    if(Llist_flag == 1)
     1822    {
    18681823        L_temp = list();
    1869         for(i = 1; i <= n; i++){
     1824        for(i = 1; i <= n; i++)
     1825        {
    18701826            L_temp[i] = list(L[i],L_sec[i]);
    18711827        }
     
    18731829        return(L_temp);
    18741830    }
    1875 
    18761831    return(L);
    1877 
    18781832}
    18791833example
     
    19181872
    19191873
    1920 ////////////////////////////////////////////////////////////////////////////////////////////////
    1921 //------------ Procedures for computing with universal derivation and differential -----------//
    1922 ////////////////////////////////////////////////////////////////////////////////////////////////
     1874////////////////////////////////////////////////////////////////////////////////
     1875//---- Procedures for computing with universal derivation and differential ---//
     1876////////////////////////////////////////////////////////////////////////////////
    19231877
    19241878
     
    19301884EXAMPLE:    example difformUnivDer; shows an example"
    19311885{
    1932 
    1933     diffAlgebraCheck();
    1934 
    1935         difform df = 0;
     1886    difform df = 0;
    19361887    difform d_var;
    1937         int n = size(ringlist(basering)[2]);
    1938         int i;
    1939 
    1940         // Build the image under the universal derivation
    1941         for(i = 1; i <= n; i++){
     1888    int n = size(ringlist(basering)[2]);
     1889    int i;
     1890
     1891    // Build the image under the universal derivation
     1892    for(i = 1; i <= n; i++)
     1893    {
    19421894        execute("d_var = d" + string(var(i)));
    19431895                df = df + diff(f,var(i))*d_var;
    1944         }
    1945 
    1946         return(df);
    1947 
     1896    }
     1897    return(df);
    19481898}
    19491899example
     
    19651915
    19661916
    1967 ////////////////////////////////////////////////////////////////////////////////////////////////
     1917////////////////////////////////////////////////////////////////////////////////
    19681918
    19691919
     
    19801930EXAMPLE:    example difformDiff; shows an example"
    19811931{
    1982 
    1983     diffAlgebraCheck();
    1984 
    19851932    difform d_df = 0;
    19861933    list df_gen_repr = difformCoef(df);
     
    19891936
    19901937    // Derivate each coefficient
    1991     for(i = 1; i <= n; i++){
     1938    for(i = 1; i <= n; i++)
     1939    {
    19921940        d_df = d_df + difformUnivDer(df_gen_repr[i][2])*df_gen_repr[i][1];
    19931941    }
    1994 
    19951942    return(d_df);
    1996 
    19971943}
    19981944example
     
    20251971
    20261972
    2027 ////////////////////////////////////////////////////////////////////////////////////////////////
    2028 ////////////////////////////////////////////////////////////////////////////////////////////////
    2029 //                               Procedures for type derivation                               //
    2030 ////////////////////////////////////////////////////////////////////////////////////////////////
    2031 ////////////////////////////////////////////////////////////////////////////////////////////////
    2032 
    2033 
    2034 ////////////////////////////////////////////////////////////////////////////////////////////////
    2035 //----------------------------------- Structural procedures ----------------------------------//
    2036 ////////////////////////////////////////////////////////////////////////////////////////////////
     1973////////////////////////////////////////////////////////////////////////////////
     1974////////////////////////////////////////////////////////////////////////////////
     1975//                      Procedures for type derivation                        //
     1976////////////////////////////////////////////////////////////////////////////////
     1977////////////////////////////////////////////////////////////////////////////////
     1978
     1979
     1980////////////////////////////////////////////////////////////////////////////////
     1981//-------------------------- Structural procedures ---------------------------//
     1982////////////////////////////////////////////////////////////////////////////////
    20371983
    20381984
     
    20511997EXAMPLE:    example derivationFromList; shows an example"
    20521998{
    2053 
    2054     diffAlgebraCheck();
    2055 
    20561999    // Check the structure of the given list
    20572000    derivationCheckList(L);
     
    20622005    derivation phi;
    20632006    phi.genIm = L;
    2064 
    20652007    return(phi);
    2066 
    20672008}
    20682009example
     
    20952036
    20962037
    2097 ////////////////////////////////////////////////////////////////////////////////////////////////
     2038////////////////////////////////////////////////////////////////////////////////
    20982039
    20992040
     
    21112052SEE ALSO:   derivationFromList, difformIsGen, difformListCont"
    21122053{
    2113 
    2114     if(size(L) != 2){
     2054    if(size(L) != 2)
     2055    {
    21152056        ERROR("Given list has wrong size!");
    21162057    }
    2117 
    2118     if(typeof(L[1]) != "list" || typeof(L[2]) != "list"){
     2058    if(typeof(L[1]) != "list" || typeof(L[2]) != "list")
     2059    {
    21192060        ERROR("Given list does not contain lists!");
    21202061    }
    2121 
    2122     if(size(L[1]) != size(L[2])){
     2062    if(size(L[1]) != size(L[2]))
     2063    {
    21232064        ERROR("Given list does not have the right form!");
    21242065    }
     
    21282069
    21292070    // Need an image for any generator
    2130     if(n != size(ringlist(basering)[2])){
     2071    if(n != size(ringlist(basering)[2]))
     2072    {
    21312073        ERROR("Given list has wrong size!");
    21322074    }
    21332075
    2134     for(i = 1; i <= n; i++){
     2076    for(i = 1; i <= n; i++)
     2077    {
    21352078        // Right type needed
    2136         if(typeof(L[1][i]) != "difform" || (typeof(L[2][i]) != "poly" && typeof(L[2][i]) != "int" && typeof(L[2][i]) != "number")){
     2079        if(typeof(L[1][i]) != "difform" || (typeof(L[2][i]) != "poly" && typeof(L[2][i]) != "int" && typeof(L[2][i]) != "number"))
     2080        {
    21372081            ERROR("Given list contains wrong type!");
    21382082        }
    21392083
    21402084        // Generator of Omega_R^1
    2141         if(!(difformIsGen(L[1][i]) && deg(L[1][i]) == 1)){
     2085        if(!(difformIsGen(L[1][i]) && deg(L[1][i]) == 1))
     2086        {
    21422087            ERROR("Given list contains a non-generator or a generator not of degree 1!");
    21432088        }
     
    21462091    // Now check the list L[1] for duplicates of the generators
    21472092    list L_i;
    2148     for(i = 1; i <= n; i++){
     2093    for(i = 1; i <= n; i++)
     2094    {
    21492095        L_i = delete(L[1],i);
    2150         if(difformListCont(L_i,L[1][i])){
     2096        if(difformListCont(L_i,L[1][i]))
     2097        {
    21512098            ERROR("Given list contains duplicate of a generator!");
    21522099        }
     
    21552102
    21562103
    2157 ////////////////////////////////////////////////////////////////////////////////////////////////
     2104////////////////////////////////////////////////////////////////////////////////
    21582105
    21592106
     
    21672114EXAMPLE:    example derivationFromPoly; shows an example"
    21682115{
    2169 
    2170     diffAlgebraCheck();
    2171 
    21722116    list L;
    21732117    // First entry of list are the degree-1 generators
     
    21792123    int n = size(L[1]);
    21802124    int i;
    2181     for(i = 1; i <= n; i++){
     2125    for(i = 1; i <= n; i++)
     2126    {
    21822127        L[2][i] = f;
    21832128    }
     
    21872132    phi.genIm = L;
    21882133    return(phi);
    2189 
    21902134}
    21912135example
     
    22062150
    22072151
    2208 ////////////////////////////////////////////////////////////////////////////////////////////////
     2152////////////////////////////////////////////////////////////////////////////////
    22092153
    22102154
     
    22202164EXAMPLE:    example derivationConstructor; shows an example"
    22212165{
    2222 
    2223     if(typeof(inp) == "list"){
     2166    if(typeof(inp) == "list")
     2167    {
    22242168        derivation der_cons = derivationFromList(inp);
    22252169        return(der_cons);
    22262170    }
    2227     if(typeof(inp) == "poly" || typeof(inp) == "number" || typeof(inp) == "int" || typeof(inp) == "bigint"){
     2171    if(typeof(inp) == "poly" || typeof(inp) == "number" || typeof(inp) == "int" || typeof(inp) == "bigint")
     2172    {
    22282173        derivation der_cons = derivationFromPoly(inp);
    22292174        return(der_cons);
     
    22662211EXAMPLE:    example derivationToString; shows an example"
    22672212{
    2268 
    2269     diffAlgebraCheck();
    22702213    list temp_genIm = phi.genIm;
    22712214
     
    22752218    int i;
    22762219
    2277     for(i = 1; i <= n; i++){
    2278         if(typeof(#[i]) == "string"){
    2279             if(#[i] == "gen" && typeof(#[i+1]) == "string"){
     2220    for(i = 1; i <= n; i++)
     2221    {
     2222        if(typeof(#[i]) == "string")
     2223        {
     2224            if(#[i] == "gen" && typeof(#[i+1]) == "string")
     2225            {
    22802226                gen_ord = #[i+1];
    2281                 if(typeof(#[i+2]) == "intvec"){
     2227                if(typeof(#[i+2]) == "intvec")
     2228                {
    22822229                    intvec gen_weight = #[i+2];
    22832230                }
     
    22872234
    22882235    // Sort the generator/coefficients by the chosen ordering
    2289     if(gen_ord != ""){
    2290         if(defined(gen_weight)){
     2236    if(gen_ord != "")
     2237    {
     2238        if(defined(gen_weight))
     2239        {
    22912240            temp_genIm = difformListSort(temp_genIm,"Dlist","gen",gen_ord,gen_weight);
    2292         }else{
     2241        }
     2242        else
     2243        {
    22932244            temp_genIm = difformListSort(temp_genIm,"Dlist","gen",gen_ord);
    22942245        }
     
    23042255    int ring_name_size = size(ring_name);
    23052256
    2306     for(i = 1; i <= n; i++){
     2257    for(i = 1; i <= n; i++)
     2258    {
    23072259        phi_out = phi_out + tab(6 + ring_name_size) + difformGenToString(gens[i]) + " |--> " + string(images[i]) + newline;
    23082260    }
    23092261
    23102262    return(phi_out);
    2311 
    23122263}
    23132264example
     
    23362287
    23372288
    2338 ////////////////////////////////////////////////////////////////////////////////////////////////
     2289////////////////////////////////////////////////////////////////////////////////
    23392290
    23402291
     
    23472298EXAMPLE:        example derivationPrint; shows an example"
    23482299{
    2349 
    23502300    // Orders the generators in ls-order
    23512301    print(derivationToString(phi,"gen","ls"));
    2352 
    23532302}
    23542303example
     
    23772326
    23782327
    2379 ////////////////////////////////////////////////////////////////////////////////////////////////
    2380 //------------------------------ Basic computational procedures ------------------------------//
    2381 ////////////////////////////////////////////////////////////////////////////////////////////////
     2328////////////////////////////////////////////////////////////////////////////////
     2329//-------------------- Basic computational procedures ------------------------//
     2330////////////////////////////////////////////////////////////////////////////////
    23822331
    23832332
     
    23922341EXAMPLE:    example derivationAdd; shows an example"
    23932342{
    2394 
    2395     diffAlgebraCheck();
    2396 
    23972343    // Structure for derivation
    23982344    derivation add_der;
     
    24052351    int i;
    24062352
    2407     for(i = 1; i <= n; i++){
     2353    for(i = 1; i <= n; i++)
     2354    {
    24082355        // Lists are sorted the same way
    24092356        add_list[2][i] = phi.genIm[2][i] + psi.genIm[2][i];
     
    24132360    add_der.genIm = add_list;
    24142361    return(add_der);
    2415 
    24162362}
    24172363example
     
    24432389
    24442390
    2445 ////////////////////////////////////////////////////////////////////////////////////////////////
     2391////////////////////////////////////////////////////////////////////////////////
    24462392
    24472393
     
    24562402EXAMPLE:    example derivationSub; shows an example"
    24572403{
    2458 
    2459     diffAlgebraCheck();
    2460 
    24612404    // Structure for derivation
    24622405    derivation sub_der;
     
    24692412    int i;
    24702413
    2471     for(i = 1; i <= n; i++){
     2414    for(i = 1; i <= n; i++)
     2415    {
    24722416        // Lists are sorted the same way
    24732417        sub_list[2][i] = phi.genIm[2][i] - psi.genIm[2][i];
     
    24772421    sub_der.genIm = sub_list;
    24782422    return(sub_der);
    2479 
    24802423}
    24812424example
     
    25072450
    25082451
    2509 ////////////////////////////////////////////////////////////////////////////////////////////////
     2452////////////////////////////////////////////////////////////////////////////////
    25102453
    25112454
     
    25172460EXAMPLE:    example derivationNeg; shows an example"
    25182461{
    2519 
    2520     diffAlgebraCheck();
    2521 
    25222462    // Structure for derivation
    25232463    derivation neg_der;
     
    25302470    int i;
    25312471
    2532     for(i = 1; i <= n; i++){
     2472    for(i = 1; i <= n; i++)
     2473    {
    25332474        neg_list[2][i] = -phi.genIm[2][i];
    25342475    }
     
    25372478    neg_der.genIm = neg_list;
    25382479    return(neg_der);
    2539 
    25402480}
    25412481example
     
    25662506
    25672507
    2568 ////////////////////////////////////////////////////////////////////////////////////////////////
     2508////////////////////////////////////////////////////////////////////////////////
    25692509
    25702510
     
    25782518EXAMPLE:    derivationMul; shows an example"
    25792519{
    2580 
    2581     diffAlgebraCheck();
    2582 
    25832520    // Structure for derivation
    25842521    derivation mul_der;
     
    25912528    int i;
    25922529
    2593     for(i = 1; i <= n; i++){
     2530    for(i = 1; i <= n; i++)
     2531    {
    25942532        // Lists are sorted the same way
    25952533        mul_list[2][i] = phi.genIm[2][i]*psi.genIm[2][i];
     
    25992537    mul_der.genIm = mul_list;
    26002538    return(mul_der);
    2601 
    26022539}
    26032540example
     
    26292566
    26302567
    2631 ////////////////////////////////////////////////////////////////////////////////////////////////
     2568////////////////////////////////////////////////////////////////////////////////
    26322569
    26332570
     
    26422579EXAMPLE:    example derivationEqu; shows an example"
    26432580{
    2644 
    2645     diffAlgebraCheck();
    2646 
    26472581    int n = size(phi.genIm[1]);
    26482582    int i;
    26492583
    2650     for(i = 1; i <= n; i++){
     2584    for(i = 1; i <= n; i++)
     2585    {
    26512586        // Lists are sorted the same way
    2652         if(phi.genIm[2][i] != psi.genIm[2][i]){
     2587        if(phi.genIm[2][i] != psi.genIm[2][i])
     2588        {
    26532589            // Different images
    26542590            return(0);
     
    26582594    // Images are the same
    26592595    return(1);
    2660 
    26612596}
    26622597example
     
    26872622
    26882623
    2689 ////////////////////////////////////////////////////////////////////////////////////////////////
     2624////////////////////////////////////////////////////////////////////////////////
    26902625
    26912626
     
    26992634EXAMPLE:    example derivationNeq; shows an example"
    27002635{
    2701 
    27022636    return(!derivationEqu(phi,psi));
    2703 
    27042637}
    27052638example
     
    27302663
    27312664
    2732 ////////////////////////////////////////////////////////////////////////////////////////////////
     2665////////////////////////////////////////////////////////////////////////////////
    27332666
    27342667
     
    27472680EXAMPLE:    example derivationEval; shows an example"
    27482681{
    2749 
    2750     diffAlgebraCheck();
    2751 
    2752     if(!homog(df)){
     2682    if(!homog(df))
     2683    {
    27532684        ERROR("Cannot apply derivation to non-homogeneous element!");
    27542685    }
    27552686
    2756     if(deg(df) != 1 && deg(df) != -1){
     2687    if(deg(df) != 1 && deg(df) != -1)
     2688    {
    27572689        ERROR("Cannot apply derivation to differential form not of degree 1!");
    27582690    }
     
    27652697    int j = 1;
    27662698
    2767     for(i = 1; i <= n; i++){
     2699    for(i = 1; i <= n; i++)
     2700    {
    27682701        // Both lists are sorted by the monomial ordering on the differential algebra
    27692702        // So the generators are sorted the same way in both lists
    27702703        // If given df does not involve all generators avoid gaps using j
    2771         if(j <= k){
    2772             if(df_gen_repr[j][1] == phi.genIm[1][i]){
     2704        if(j <= k)
     2705        {
     2706            if(df_gen_repr[j][1] == phi.genIm[1][i])
     2707            {
    27732708                df_eval = df_eval + df_gen_repr[j][2]*phi.genIm[2][i];
    27742709                j++;
     
    27762711        }
    27772712    }
    2778 
    27792713    return(df_eval);
    2780 
    27812714}
    27822715example
     
    28192752
    28202753
    2821 ////////////////////////////////////////////////////////////////////////////////////////////////
    2822 //----------------------- Procedures for computing the Lie-Derivative ------------------------//
    2823 ////////////////////////////////////////////////////////////////////////////////////////////////
     2754////////////////////////////////////////////////////////////////////////////////
     2755//------------ Procedures for computing the Lie-Derivative -------------------//
     2756////////////////////////////////////////////////////////////////////////////////
    28242757
    28252758
     
    28342767SEE ALSO:   derivationContraction"
    28352768{
    2836 
    28372769    // Sort the list, that dx_1 is the first form, dx_2 the second,...
    28382770    list gen_list = phi.genIm[1];
     
    28452777
    28462778    // Go through all degree-1 generators and test if, dx_i occurs in d_gen
    2847     for(i = 1; i <= n; i++){
    2848         if(d_gen / gen_list[i] != 0){
     2779    for(i = 1; i <= n; i++)
     2780    {
     2781        if(d_gen / gen_list[i] != 0)
     2782        {
    28492783            applic = applic + ((-1)^(j+1))*derivationEval(phi,gen_list[i])*(d_gen/gen_list[i]);
    28502784            j++;
     
    28552789
    28562790
    2857 ////////////////////////////////////////////////////////////////////////////////////////////////
     2791////////////////////////////////////////////////////////////////////////////////
    28582792
    28592793
     
    28692803EXAMPLE:    example derivationContraction; shows an example"
    28702804{
    2871 
    2872     diffAlgebraCheck();
    2873 
    28742805    list coef_list = difformCoef(df);
    28752806    int k = size(coef_list);
     
    28782809
    28792810    // Apply the contraction map to the generators since it is linear
    2880     for(i = 1; i <= k; i++){
     2811    for(i = 1; i <= k; i++)
     2812    {
    28812813        applic = applic + coef_list[i][2]*derivationContractionGen(phi,coef_list[i][1]);
    28822814    }
    2883 
    28842815    return(applic);
    2885 
    28862816}
    28872817example
     
    29172847
    29182848
    2919 ////////////////////////////////////////////////////////////////////////////////////////////////
     2849////////////////////////////////////////////////////////////////////////////////
    29202850
    29212851
     
    29302860EXAMPLE:    example derivationLie; shows an example"
    29312861{
    2932 
    29332862    difform lie_form = derivationContraction(phi,difformDiff(df)) + difformDiff(derivationContraction(phi,df));
    29342863    return(lie_form);
    2935 
    29362864}
    29372865example
     
    29692897
    29702898
    2971 ////////////////////////////////////////////////////////////////////////////////////////////////
    2972 ////////////////////////////////////////////////////////////////////////////////////////////////
    2973 
    2974 
    2975 ////////////////////////////////////////////////////////////////////////////////////////////////
    2976 ////////////////////////////////////////////////////////////////////////////////////////////////
    2977 //                                       Test examples                                        //
    2978 ////////////////////////////////////////////////////////////////////////////////////////////////
    2979 ////////////////////////////////////////////////////////////////////////////////////////////////
     2899////////////////////////////////////////////////////////////////////////////////
     2900////////////////////////////////////////////////////////////////////////////////
     2901
     2902
     2903////////////////////////////////////////////////////////////////////////////////
     2904////////////////////////////////////////////////////////////////////////////////
     2905//                             Test examples                                  //
     2906////////////////////////////////////////////////////////////////////////////////
     2907////////////////////////////////////////////////////////////////////////////////
    29802908
    29812909
    29822910// EXAMPLE: differential algebra over ring of characteristic 0
    2983 proc diffAlgebra_example_1(){
     2911proc diffAlgebra_example_1()
     2912{
    29842913    ring R = 0,(x,y,z),dp;
    29852914    diffAlgebra();
    2986 
    29872915    exportto(Top,R);
    29882916}
    29892917
    29902918
    2991 ////////////////////////////////////////////////////////////////////////////////////////////////
     2919////////////////////////////////////////////////////////////////////////////////
    29922920
    29932921
    29942922// EXAMPLE: differential algebra over big ring of characteristic 0 and block ordering
    2995 proc diffAlgebra_example_2(){
     2923proc diffAlgebra_example_2()
     2924{
    29962925    ring R = 0,(a,b,x,y,z,t,s,e,r,w,i),(ls(3),dp(4),lp);
    29972926    diffAlgebra();
    2998 
    29992927    exportto(Top,R);
    30002928}
    30012929
    30022930
    3003 ////////////////////////////////////////////////////////////////////////////////////////////////
     2931////////////////////////////////////////////////////////////////////////////////
    30042932
    30052933
    30062934// EXAMPLE: differential algebra over ring of positive characteristic
    3007 proc diffAlgebra_example_3(){
     2935proc diffAlgebra_example_3()
     2936{
    30082937    ring R = 31,(a,b,x),dp;
    30092938    diffAlgebra();
    3010 
    30112939    exportto(Top,R);
    30122940}
    30132941
    30142942
    3015 ////////////////////////////////////////////////////////////////////////////////////////////////
     2943////////////////////////////////////////////////////////////////////////////////
    30162944
    30172945
    30182946// EXAMPLE: differential algebra over quotient ring
    3019 proc diffAlgebra_example_4(){
     2947proc diffAlgebra_example_4()
     2948{
    30202949    ring S = 0,(x,y,z),lp;
    30212950    ideal I = x2-y4,xyz;
    30222951    qring R = std(I);
    30232952    diffAlgebra();
    3024 
    30252953    exportto(Top,R);
    30262954}
    30272955
    30282956
    3029 ////////////////////////////////////////////////////////////////////////////////////////////////
     2957////////////////////////////////////////////////////////////////////////////////
    30302958
    30312959
    30322960// EXAMPLE: differential form over ring of characteristic 0
    3033 proc difform_example_1(){
     2961proc difform_example_1()
     2962{
    30342963    ring R = 0,(x,y,z),ds;
    30352964    diffAlgebra();
     
    30422971
    30432972
    3044 ////////////////////////////////////////////////////////////////////////////////////////////////
     2973////////////////////////////////////////////////////////////////////////////////
    30452974
    30462975
    30472976// EXAMPLE: differential form over ring of positive characteristic
    3048 proc difform_example_2(){
     2977proc difform_example_2()
     2978{
    30492979    ring R = 31,(x,y,z,a,b,c),lp;
    30502980    diffAlgebra();
     
    30572987
    30582988
    3059 ////////////////////////////////////////////////////////////////////////////////////////////////
     2989////////////////////////////////////////////////////////////////////////////////
    30602990
    30612991
    30622992// EXAMPLE: derivation by list
    3063 proc derivation_example_1(){
     2993proc derivation_example_1()
     2994{
    30642995    ring R = 0,(x,y,z),lp;
    30652996    diffAlgebra();
     
    30763007
    30773008
    3078 ////////////////////////////////////////////////////////////////////////////////////////////////
     3009////////////////////////////////////////////////////////////////////////////////
    30793010
    30803011
    30813012// EXAMPLE: derivation by list
    3082 proc derivation_example_2(){
     3013proc derivation_example_2()
     3014{
    30833015    ring R = 0,(a,b,c,x,y,z),lp;
    30843016    diffAlgebra();
     
    30943026
    30953027
    3096 ////////////////////////////////////////////////////////////////////////////////////////////////
     3028////////////////////////////////////////////////////////////////////////////////
    30973029
    30983030
    30993031// EXAMPLE: derivations by list
    3100 proc derivation_example_3(){
     3032proc derivation_example_3()
     3033{
    31013034    ring R = 0,(x,y,z),dp;
    31023035    diffAlgebra();
     
    31213054}
    31223055
    3123 
Note: See TracChangeset for help on using the changeset viewer.