]> www.ginac.de Git - ginac.git/blobdiff - ginac/lorentzidx.cpp
- added documentation for the idx, coloridx and lorentzidx classes
[ginac.git] / ginac / lorentzidx.cpp
index d03d9b7a0c991ce1420eb7f518ce170ba471a4ad..500fcb85f271bfb7d53c30a6b139818590403b34 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's lorentz indices. */
 
 /*
- *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -44,14 +44,14 @@ lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0)
 {
        debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
        // serial is incremented in idx::idx()
-       name="mu"+ToString(serial);
-       tinfo_key=TINFO_lorentzidx;
+       name = "mu" + ToString(serial);
+       tinfo_key = TINFO_lorentzidx;
 }
 
 lorentzidx::~lorentzidx() 
 {
        debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
-       destroy(0);
+       destroy(false);
 }
 
 lorentzidx::lorentzidx(const lorentzidx & other)
@@ -64,7 +64,7 @@ const lorentzidx & lorentzidx::operator=(const lorentzidx & other)
 {
        debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
        if (this != &other) {
-               destroy(1);
+               destroy(true);
                copy(other);
        }
        return *this;
@@ -90,8 +90,14 @@ void lorentzidx::destroy(bool call_parent)
 
 // public
 
-lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
-       idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
+/** Construct symbolic Lorentz index, using an automatically generated unique name.
+ *
+ *  @param cov Index is covariant (contravariant otherwise)
+ *  @param oonly Index only lives in orthogonal space
+ *  @param dimp Dimension of parallel space
+ *  @return newly constructed index */
+lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp)
+  : idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
 {
        debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
        // serial is incremented in idx::idx(bool)
@@ -103,24 +109,43 @@ lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
        tinfo_key=TINFO_lorentzidx;
 }
 
+/** Construct symbolic Lorentz index with specified name.
+ *
+ *  @param n Symbolic index name
+ *  @param cov Index is covariant (contravariant otherwise)
+ *  @param oonly Index only lives in orthogonal space
+ *  @param dimp Dimension of parallel space
+ *  @return newly constructed index */
 lorentzidx::lorentzidx(const std::string & n, bool cov, bool oonly, unsigned dimp)
-       : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
+  : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
 {
        debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
                         LOGLEVEL_CONSTRUCT);
        tinfo_key=TINFO_lorentzidx;
 }
 
+/** Construct symbolic Lorentz index with specified name.
+ *
+ *  @param n Symbolic index name
+ *  @param cov Index is covariant (contravariant otherwise)
+ *  @param oonly Index only lives in orthogonal space
+ *  @param dimp Dimension of parallel space
+ *  @return newly constructed index */
 lorentzidx::lorentzidx(const char * n, bool cov, bool oonly, unsigned dimp)
-       : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
+  : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
 {
        debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
                         LOGLEVEL_CONSTRUCT);
        tinfo_key=TINFO_lorentzidx;
 }
 
-lorentzidx::lorentzidx(unsigned v, bool cov) : idx(v,cov),
-       orthogonal_only(false), dim_parallel_space(0)
+/** Construct numeric Lorentz index with specified value.
+ *
+ *  @param v Numeric index value
+ *  @param cov Index is covariant (contravariant otherwise)
+ *  @return newly constructed index */
+lorentzidx::lorentzidx(unsigned v, bool cov)
+  : idx(v,cov), orthogonal_only(false), dim_parallel_space(0)
 {
        debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
        tinfo_key=TINFO_lorentzidx;
@@ -135,8 +160,7 @@ lorentzidx::lorentzidx(const archive_node &n, const lst &sym_lst) : inherited(n,
 {
        debugmsg("lorentzidx constructor from archive_node", LOGLEVEL_CONSTRUCT);
        n.find_bool("orthogonal_only", orthogonal_only);
-       if (orthogonal_only)
-               n.find_unsigned("pdim", dim_parallel_space);
+       n.find_unsigned("pdim", dim_parallel_space);
 }
 
 /** Unarchive the object. */
@@ -159,8 +183,7 @@ void lorentzidx::archive(archive_node &n) const
 {
        inherited::archive(n);
        n.add_bool("orthogonal_only", orthogonal_only);
-       if (orthogonal_only)
-               n.add_unsigned("pdim", dim_parallel_space);
+       n.add_unsigned("pdim", dim_parallel_space);
 }
 
 //////////
@@ -270,6 +293,7 @@ bool lorentzidx::info(unsigned inf) const
 
 // public
 
+/** Create anonymous contravariant copy of a symbolic Lorentz index. */
 lorentzidx lorentzidx::create_anonymous_representative(void) const
 {
        GINAC_ASSERT(is_symbolic());
@@ -277,8 +301,8 @@ lorentzidx lorentzidx::create_anonymous_representative(void) const
        i_copy.serial=0;
        i_copy.name="anonymous_representative";
        i_copy.covariant=false;
-       i_copy.clearflag(status_flags::dynallocated|
-                                        status_flags::hash_calculated);
+       i_copy.clearflag(status_flags::dynallocated |
+                        status_flags::hash_calculated);
        return i_copy;
 }
 
@@ -293,7 +317,7 @@ lorentzidx lorentzidx::create_anonymous_representative(void) const
 //////////
 
 const lorentzidx some_lorentzidx;
-const type_info & typeid_lorentzidx=typeid(some_lorentzidx);
+const std::type_info & typeid_lorentzidx = typeid(some_lorentzidx);
 
 #ifndef NO_NAMESPACE_GINAC
 } // namespace GiNaC