Coverage Report - net.sourceforge.combean.mathprog.linalg.statics.SparseVectorStringifier
 
Classes in this File Line Coverage Branch Coverage Complexity
SparseVectorStringifier
0%
0/11
0%
0/2
0
 
 1  
 /*
 2  
  * Created on 11.04.2008
 3  
  *
 4  
  */
 5  
 package net.sourceforge.combean.mathprog.linalg.statics;
 6  
 
 7  
 import net.sourceforge.combean.interfaces.mathprog.linalg.SparseVec;
 8  
 import net.sourceforge.combean.interfaces.mathprog.linalg.VectorIterator;
 9  
 import net.sourceforge.combean.interfaces.mathprog.linalg.VectorValue;
 10  
 
 11  
 /**
 12  
  * Collection of static utility methods for representing sparse vectors as strings.
 13  
  * 
 14  
  * @author schickin
 15  
  *
 16  
  */
 17  0
 public class SparseVectorStringifier {
 18  
 
 19  
     /**
 20  
      * Represent a sparse vector as string
 21  
      * 
 22  
      * @param <Label>
 23  
      * @param svec the sparse vector to be converted to a string
 24  
      * @return string representation of svec
 25  
      */
 26  
     public static <Label> String convertToString(SparseVec<Label> svec) {
 27  0
         StringBuffer result = new StringBuffer();
 28  
         
 29  0
         result.append("LPSparseVector { ");
 30  
         
 31  0
         result.append(" values {");
 32  0
         VectorIterator<Label> itVec = svec.iterator();
 33  0
         while (itVec.hasNext()) {
 34  0
             VectorValue<Label> val = itVec.next();
 35  0
             result.append(" " + val.label() + "[" + val.index() + "]=" +
 36  
                     val.doubleValue());
 37  
             
 38  0
         }
 39  0
         result.append(" } }");
 40  
         
 41  0
         return result.toString();
 42  
     }
 43  
 
 44  
 }