From f13eacbc8e5ab714dd3544adab8189c313382c77 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 22 Jul 2015 13:55:29 +0000 Subject: Support for non-commuting fields --- src/definitions.cpp | 2 +- src/fields.c | 125 +++++++++++++++++++++++++++++++++++-------- src/fields.h | 4 ++ src/kondo.c | 150 +++++++++++++++++++++++++--------------------------- src/kondo.h | 2 +- src/mean.c | 8 +-- src/parse_file.c | 24 ++++++--- src/polynomial.c | 60 ++++++++++++++++++--- src/polynomial.h | 8 ++- src/types.h | 2 + 10 files changed, 266 insertions(+), 119 deletions(-) (limited to 'src') diff --git a/src/definitions.cpp b/src/definitions.cpp index 982f7a7..1884488 100644 --- a/src/definitions.cpp +++ b/src/definitions.cpp @@ -17,7 +17,7 @@ limitations under the License. #ifndef DEFINITIONS_GCC #define DEFINITIONS_GCC -#define VERSION "1.2.1" +#define VERSION "1.3" // number of entries in a configuration file #define ARG_COUNT 10 diff --git a/src/fields.c b/src/fields.c index 1b221f2..bfd1f39 100644 --- a/src/fields.c +++ b/src/fields.c @@ -32,6 +32,7 @@ int init_Fields_Table(Fields_Table* fields){ init_Identities(&((*fields).ids), FIELDS_SIZE); init_Symbols(&((*fields).symbols), FIELDS_SIZE); init_Int_Array(&((*fields).fermions),FIELDS_SIZE); + init_Int_Array(&((*fields).noncommuting),FIELDS_SIZE); return(0); } int free_Fields_Table(Fields_Table fields){ @@ -41,6 +42,7 @@ int free_Fields_Table(Fields_Table fields){ free_Identities(fields.ids); free_Symbols(fields.symbols); free_Int_Array(fields.fermions); + free_Int_Array(fields.noncommuting); return(0); } @@ -73,6 +75,16 @@ int is_fermion(int index, Fields_Table fields){ } } +// check whether a field is non-commuting +int is_noncommuting(int index, Fields_Table fields){ + if(int_array_find(abs(index), fields.noncommuting)>=0){ + return(1); + } + else{ + return(0); + } +} + // ------------------ Identities -------------------- @@ -180,13 +192,16 @@ int identities_concat(Identities input, Identities* output){ // resolve the identities // requires both the monomials in polynomial and the ids in fields to be sorted +// IMPORTANT: the sorting must be such that noncommuting fields must come before the other fields int resolve_ids(Polynomial* polynomial, Fields_Table fields){ int i,j,k,l; int sign; int fermion_count; + int first_field; int at_least_one; int security; - Int_Array monomial; + Int_Array pre_monomial; + Int_Array post_monomial; Number num; Number tmp_num; @@ -207,29 +222,38 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){ // loop over ids for(j=0;j=0){ + init_Int_Array(&pre_monomial, (*polynomial).monomials[i].length); + init_Int_Array(&post_monomial, (*polynomial).monomials[i].length); + + // add whatever is before the first field to pre + for(k=0;k=fields.ids.lhs[j].length || (*polynomial).monomials[i].values[k]!=fields.ids.lhs[j].values[l]){ - int_array_append((*polynomial).monomials[i].values[k],&monomial); - // sign correction - if(fermion_count % 2 ==1 && is_fermion((*polynomial).monomials[i].values[k], fields)){ - sign*=-1; + // add to post + int_array_append((*polynomial).monomials[i].values[k],&post_monomial); + // count Fermions to jump + if(is_fermion((*polynomial).monomials[i].values[k],fields)){ + fermion_count++; } } else{ - // increment fermion_count - if(is_fermion(fields.ids.lhs[j].values[l],fields)){ - fermion_count++; + // sign correction + if(is_fermion(fields.ids.lhs[j].values[l],fields) && fermion_count % 2 == 1){ + sign*=-1; } // increment "current" field in the id l++; @@ -240,30 +264,33 @@ int resolve_ids(Polynomial* polynomial, Fields_Table fields){ // add extra monomials (if there are more than 1) for(k=1;k0){ + matches=post_nc; + } + else{ + matches=1; + } + + for(i=first+1;i0){ for(i=0;i=0){ @@ -1001,8 +977,8 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){ } } - // h's - if(offset==KONDO_H_OFFSET){ + // h's and t's + if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){ // external field init_Int_Array(&monomial,1); init_Int_Array(&factor,1); @@ -1062,7 +1038,7 @@ int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields){ // read a Kondo scalar product (generalized to vector products as well) int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields){ char* ptr; - // offset of each term (A,B or H) + // offset of each term (A,B,H or T) int offset=-1; // index of each term (0,...,box_count) int index=0; @@ -1091,6 +1067,9 @@ int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields case 'h': offset=KONDO_H_OFFSET; break; + case 't': + offset=KONDO_T_OFFSET; + break; // scalar product case '.': @@ -1195,8 +1174,8 @@ int kondo_polynomial_vector(int offset, int index, Polynomial (*polys)[3], Field init_Polynomial((*polys)+i,POLY_SIZE); } - // h's - if(offset==KONDO_H_OFFSET){ + // h's and t's + if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){ // construct every component field for(i=0;i=0){ @@ -1443,8 +1439,8 @@ int get_symbol_index(char* str){ if(offset==-1){ return(-1); } - // no symbol for h - if(offset==KONDO_H_OFFSET){ + // no symbol for h or t + if(offset==KONDO_H_OFFSET || offset==KONDO_T_OFFSET){ return(10*(10*offset+dim)); } else{ diff --git a/src/kondo.h b/src/kondo.h index 23756ad..c534145 100644 --- a/src/kondo.h +++ b/src/kondo.h @@ -55,7 +55,7 @@ int parse_kondo_polynomial_str(char* str_polynomial, Polynomial* output, Fields_ int parse_kondo_polynomial(Char_Array kondo_polynomial_str, Polynomial* polynomial, Fields_Table fields); // read Aij, Bij, hi where i is a space dimension and j is a box index -int kondo_resolve_ABh(char* str, Polynomial* output, Fields_Table fields); +int kondo_resolve_ABht(char* str, Polynomial* output, Fields_Table fields); // read a Kondo scalar product int kondo_resolve_scalar_prod(char* str, Polynomial* output, Fields_Table fields); // compute a scalar product of polynomial vectors diff --git a/src/mean.c b/src/mean.c index aad7a5a..39ece56 100644 --- a/src/mean.c +++ b/src/mean.c @@ -42,7 +42,7 @@ int mean(Int_Array monomial, Polynomial* out, Fields_Table fields, Polynomial_Ma *out=polynomial_one(); // sort first - monomial_sort(monomial, 0, monomial.length-1, fields, &sign); + monomial_sort(monomial, fields, &sign); polynomial_multiply_Qscalar(*out, quot(sign,1)); // get internals // (*out).monomials is the first element of out but it only has 1 element @@ -417,7 +417,7 @@ int mean_symbols(Int_Array monomial, Polynomial* output, Fields_Table fields, Po if(check_monomial_match(tmp_monomial, fields)==1){ // sort monomial sign=1; - monomial_sort(tmp_monomial, 0, tmp_monomial.length-1, fields, &sign); + monomial_sort(tmp_monomial, fields, &sign); number_Qprod_chain(quot(sign,1), &tmp_num); // mean @@ -628,7 +628,7 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol init_Polynomial(output, MONOMIAL_SIZE); // check whether there are symbols - // requires the symbols to be at the end of the monomial + // IMPORTANT: the symbols must be at the end of the monomial if(monomial.length==0 || field_type(monomial.values[monomial.length-1], fields)!=FIELD_SYMBOL){ // mean mean(monomial, &num_mean, fields, propagator); @@ -639,7 +639,7 @@ int mean_groups(Int_Array monomial, Polynomial* output, Fields_Table fields, Pol // sort into groups if(groups.length>0){ sign=1; - monomial_sort_groups(monomial, 0, monomial.length-1, fields, groups, &sign); + monomial_sort_groups(monomial, fields, groups, &sign); } // construct groups and take mean init_Int_Array(&tmp_monomial, MONOMIAL_SIZE); diff --git a/src/parse_file.c b/src/parse_file.c index 6054372..19b91c6 100644 --- a/src/parse_file.c +++ b/src/parse_file.c @@ -44,16 +44,17 @@ limitations under the License. #define PP_EXTERNAL_MODE 8 #define PP_INTERNAL_MODE 9 #define PP_FERMIONS_MODE 10 +#define PP_NONCOMMUTING_MODE 11 // indices -#define PP_INDEX_MODE 11 +#define PP_INDEX_MODE 12 // factors or monomials -#define PP_BRACKET_MODE 12 +#define PP_BRACKET_MODE 13 // labels -#define PP_LABEL_MODE 13 +#define PP_LABEL_MODE 14 // polynomial -#define PP_POLYNOMIAL_MODE 14 +#define PP_POLYNOMIAL_MODE 15 // group -#define PP_GROUP_MODE 15 +#define PP_GROUP_MODE 16 // parse fields list @@ -101,6 +102,11 @@ int parse_input_fields(Char_Array str_fields, Fields_Table* fields){ mode=PP_FERMIONS_MODE; } break; + case 'a': + if(mode==PP_NULL_MODE){ + mode=PP_NONCOMMUTING_MODE; + } + break; // reset buffer case ':': @@ -123,6 +129,9 @@ int parse_input_fields(Char_Array str_fields, Fields_Table* fields){ else if(mode==PP_FERMIONS_MODE){ int_array_append(i,&((*fields).fermions)); } + else if(mode==PP_NONCOMMUTING_MODE){ + int_array_append(i,&((*fields).noncommuting)); + } buffer_ptr=buffer; *buffer_ptr='\0'; break; @@ -142,6 +151,9 @@ int parse_input_fields(Char_Array str_fields, Fields_Table* fields){ else if(mode==PP_FERMIONS_MODE){ int_array_append(i,&((*fields).fermions)); } + else if(mode==PP_NONCOMMUTING_MODE){ + int_array_append(i,&((*fields).noncommuting)); + } mode=PP_NULL_MODE; break; @@ -417,7 +429,7 @@ int parse_input_identities(Char_Array str_identities, Fields_Table* fields){ (*fields).ids.length=0; for(i=0;ipost_nc;j--){ + monomial.values[j]=monomial.values[j-1]; + } + monomial.values[post_nc]=tmp; + post_nc++; + } + } + + monomial_sort_nonc(monomial, post_nc, monomial.length-1, fields, sign); + + return(0); +} +// without noncommuting terms +int monomial_sort_nonc(Int_Array monomial, int begin, int end, Fields_Table fields, int* sign){ int i; int index; // the pivot: middle of the monomial @@ -812,8 +835,8 @@ int monomial_sort(Int_Array monomial, int begin, int end, Fields_Table fields, i exchange_monomial_terms(monomial, index, end, fields, sign); // recurse - monomial_sort(monomial, begin, index-1, fields, sign); - monomial_sort(monomial, index+1, end, fields, sign); + monomial_sort_nonc(monomial, begin, index-1, fields, sign); + monomial_sort_nonc(monomial, index+1, end, fields, sign); } return(0); } @@ -872,7 +895,30 @@ int exchange_monomial_terms(Int_Array monomial, int pos1, int pos2, Fields_Table // sort a monomial by putting each group together -int monomial_sort_groups(Int_Array monomial, int begin, int end, Fields_Table fields, Groups groups, int* sign){ +// if the monomial contains noncommuting elements, put them at the beginning of the monomial +int monomial_sort_groups(Int_Array monomial, Fields_Table fields, Groups groups, int* sign){ + int i,j; + int tmp; + // first index after noncommuting indices + int post_nc=0; + + for(i=0;i