+/** This class holds an index with a variance (co- or contravariant). There
+ * is an associated metric tensor that can be used to raise/lower indices. */
+class varidx : public idx
+{
+ GINAC_DECLARE_REGISTERED_CLASS(varidx, idx)
+
+ // other constructors
+public:
+ /** Construct index with given value, dimension and variance.
+ *
+ * @param v Value of index (numeric or symbolic)
+ * @param dim Dimension of index space (numeric or symbolic)
+ * @param covariant Make covariant index (default is contravariant)
+ * @return newly constructed index */
+ varidx(const ex & v, const ex & dim, bool covariant = false);
+
+ // functions overriding virtual functions from bases classes
+public:
+ void print(std::ostream & os, unsigned upper_precedence=0) const;
+ bool is_dummy_pair_same_type(const basic & other) const;
+
+ // non-virtual functions in this class
+public:
+ /** Check whether the index is covariant. */
+ bool is_covariant(void) const {return covariant;}
+
+ /** Check whether the index is contravariant (not covariant). */
+ bool is_contravariant(void) const {return !covariant;}
+
+ /** Make a new index with the same value but the opposite variance. */
+ ex toggle_variance(void) const;
+
+ // member variables
+protected:
+ bool covariant; /**< x.mu, default is contravariant: x~mu */
+};
+