00001 /* 00002 * Copyright 2007 Martin von Gagern 00003 * 00004 * 00005 * This file is part of mqn2mps. 00006 * 00007 * mqn2mps is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * mqn2mps is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 00022 #ifndef CONSTRAINT_HH 00023 #define CONSTRAINT_HH 00024 00025 /** 00026 * @file 00027 * Interface of class constraint. 00028 */ 00029 00030 /** 00031 * A equality constrained row of the output problem formulation. 00032 * 00033 * In terms of the matrix of a linear program, a constraint object 00034 * describes a single row as a whole, giving its name and rules, but 00035 * not the matrix elements, which will be included in the columns 00036 * represented by field objects. 00037 * 00038 * A constraint represented through this class is an equality 00039 * constraint for the sum over a specified component of each field 00040 * description. The component is identified by name. The calculation 00041 * might use modulo arithmetic. 00042 * 00043 * Some special rows may created which are not representet as 00044 * constraint objects internally, e.g. because they are inequalities. 00045 */ 00046 class constraint { 00047 public: 00048 00049 /** 00050 * The name of the quantum number for which this constraint must 00051 * hold. 00052 * This is used as a lookup to identify the comonent inside the 00053 * field descriptions. 00054 * 00055 * @see driver::indices 00056 */ 00057 std::string name; 00058 00059 /** 00060 * The right hand side of the euqality. 00061 * Both the lower and the upper bound of the row will have this 00062 * value. 00063 */ 00064 rational goal; 00065 00066 /** 00067 * The divisor for modulo arithmetic. 00068 * The special value 0 means that no modulo arithmetic should be 00069 * used. 00070 */ 00071 int mod; 00072 00073 constraint(); 00074 constraint(std::string* name, rational* goal, int mod); 00075 constraint(std::string name, rational goal, int mod); 00076 void swap(constraint& other); 00077 00078 }; 00079 00080 namespace std { 00081 00082 /** 00083 * Specialization of swap operation for constraint references. 00084 * This allows efficient swapping in generic algorithms. 00085 * All members of the class will be swapped individually, which 00086 * avoids a bit of overhead that would result from assignments in 00087 * the default implementation. 00088 * 00089 * @param a reference of one object to be swapped. 00090 * @param b reference of the other object to be swapped. 00091 */ 00092 template<> inline void swap(constraint& a, constraint& b) { 00093 a.swap(b); 00094 } 00095 00096 } 00097 00098 #endif // ifndef CONSTRAINT_HH
1.6.0