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 FIELD_HH 00023 #define FIELD_HH 00024 00025 /** 00026 * @file 00027 * Interface of class field. 00028 */ 00029 00030 /** 00031 * A column of the output problem formulation, along with its values. 00032 * 00033 * In terms of the matrix of a linear program, a field object 00034 * describes a single column, giving its name as well as the matrix 00035 * elements in that column. 00036 * 00037 * Columns may come directly from the input field description, but 00038 * additional columns are created during problem transformation, and 00039 * most will be expressed through an object of this class as well. 00040 * 00041 * The object does not store any information about the bounds of the 00042 * variable associated with this column. 00043 */ 00044 class field { 00045 public: 00046 00047 /** 00048 * The name of the column. 00049 * If the object belongs to a field from the input description, the 00050 * field name given there will be stored. For internally generated 00051 * columns, unique names starting with an underscore will be 00052 * chosen. 00053 */ 00054 std::string name; 00055 00056 /** 00057 * The matrix elements of the column. 00058 * The values correspond to quantum numbers according to the order 00059 * stored in driver::names. 00060 */ 00061 std::vector<rational> values; 00062 00063 field(); 00064 field(std::string* name, std::vector<rational>* values); 00065 void swap(field& other); 00066 00067 }; 00068 00069 namespace std { 00070 00071 /** 00072 * Specialization of swap operation for field references. 00073 * This allows efficient swapping in generic algorithms. 00074 * All members of the class will be swapped individually, which 00075 * avoids a bit of overhead that would result from assignments in 00076 * the default implementation. 00077 * 00078 * @param a reference of one object to be swapped. 00079 * @param b reference of the other object to be swapped. 00080 */ 00081 template<> inline void swap(field& a, field& b) { 00082 a.swap(b); 00083 } 00084 00085 } 00086 00087 #endif // ifndef FIELD_HH
1.6.0