Scippy

SoPlex

Sequential object-oriented simPlex

ssvectorbase.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2016 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 
17 /**@file ssvectorbase.h
18  * @brief Semi sparse vector.
19  */
20 #ifndef _SSVECTORBASE_H_
21 #define _SSVECTORBASE_H_
22 
23 #include <assert.h>
24 
25 #include "spxdefines.h"
26 #include "dvectorbase.h"
27 #include "idxset.h"
28 #include "spxalloc.h"
29 
30 namespace soplex
31 {
32 template < class R > class SVectorBase;
33 template < class R > class SVSetBase;
34 
35 /**@brief Semi sparse vector.
36  * @ingroup Algebra
37  *
38  * This class implements semi-sparse vectors. Such are #DVectorBase%s where the indices of its nonzero elements can be
39  * stored in an extra IdxSet. Only elements with absolute value > #epsilon are considered to be nonzero. Since really
40  * storing the nonzeros is not always convenient, an SSVectorBase provides two different stati: setup and not setup.
41  * An SSVectorBase being setup means that the nonzero indices are available, otherwise an SSVectorBase is just an
42  * ordinary DVectorBase with an empty IdxSet. Note that due to arithmetic operation, zeros can slip in, i.e., it is
43  * only guaranteed that at least every non-zero is in the IdxSet.
44  */
45 template < class R >
46 class SSVectorBase : public DVectorBase<R>, protected IdxSet
47 {
48 private:
49 
50  friend class DVectorBase<R>;
51  friend class VectorBase<R>;
52  template < class S > friend class DSVectorBase;
53 
54  // ------------------------------------------------------------------------------------------------------------------
55  /**@name Data */
56  //@{
57 
58  /// Is the SSVectorBase set up?
60 
61  /// A value x with |x| < epsilon is considered zero.
63 
64  /// Allocates enough space to accommodate \p newmax values.
65  void setMax(int newmax)
66  {
67  assert(idx != 0);
68  assert(newmax != 0);
69  assert(newmax >= IdxSet::size());
70 
71  len = newmax;
73  }
74 
75  //@}
76 
77 public:
78 
79  // ------------------------------------------------------------------------------------------------------------------
80  /**@name Status of an SSVectorBase
81  *
82  * An SSVectorBase can be set up or not. In case it is set up, its IdxSet correctly contains all indices of nonzero
83  * elements of the SSVectorBase. Otherwise, it does not contain any useful data. Whether or not an SSVectorBase is
84  * setup can be determined with the method \ref soplex::SSVectorBase::isSetup() "isSetup()".
85  *
86  * There are three methods for directly affecting the setup status of an SSVectorBase:
87  *
88  * - unSetup(): This method sets the status to ``not setup''.
89  *
90  * - setup(): This method initializes the IdxSet to the SSVectorBase's nonzero indices and sets the status to
91  * ``setup''.
92  *
93  * - forceSetup(): This method sets the status to ``setup'' without verifying that the IdxSet correctly contains all
94  * nonzero indices. It may be used when the nonzero indices have been computed externally.
95  */
96  //@{
97 
98  /// Only used in slufactor.cpp.
99  R* get_ptr()
100  {
101  return DVectorBase<R>::get_ptr();
102  }
103  /// Returns the non-zero epsilon used.
104  R getEpsilon() const
105  {
106  return epsilon;
107  }
108 
109  /// Changes the non-zero epsilon, invalidating the setup. */
110  void setEpsilon(R eps)
111  {
112  if( eps != epsilon )
113  {
114  epsilon = eps;
115  setupStatus = false;
116  }
117  }
118 
119  /// Returns setup status.
120  bool isSetup() const
121  {
122  return setupStatus;
123  }
124 
125  /// Makes SSVectorBase not setup.
126  void unSetup()
127  {
128  setupStatus = false;
129  }
130 
131  /// Initializes nonzero indices for elements with absolute values above #epsilon and sets all other elements to 0.
132  void setup()
133  {
134  if( !isSetup() )
135  {
136  IdxSet::clear();
137 
138  int d = dim();
139  num = 0;
140 
141  for( int i = 0; i < d; ++i )
142  {
143  if( VectorBase<R>::val[i] != R(0) )
144  {
145  if( spxAbs(VectorBase<R>::val[i]) <= epsilon )
146  VectorBase<R>::val[i] = R(0);
147  else
148  {
149  idx[num] = i;
150  num++;
151  }
152  }
153  }
154 
155  setupStatus = true;
156 
157  assert(isConsistent());
158  }
159  }
160 
161  /// Forces setup status.
162  void forceSetup()
163  {
164  setupStatus = true;
165  }
166 
167  //@}
168 
169  // ------------------------------------------------------------------------------------------------------------------
170  /**@name Methods for setup SSVectorBases */
171  //@{
172 
173  /// Returns index of the \p n 'th nonzero element.
174  int index(int n) const
175  {
176  assert(isSetup());
177 
178  return IdxSet::index(n);
179  }
180 
181  /// Returns value of the \p n 'th nonzero element.
182  R value(int n) const
183  {
184  assert(isSetup());
185  assert(n >= 0 && n < size());
186 
187  return VectorBase<R>::val[idx[n]];
188  }
189 
190  /// Returns the position number of index \p i, or -1 if \p i doesn't exist.
191  int number(int i) const
192  {
193  assert(isSetup());
194 
195  return IdxSet::number(i);
196  }
197 
198  /// Returns the number of nonzeros.
199  int size() const
200  {
201  assert(isSetup());
202 
203  return IdxSet::size();
204  }
205 
206  /// Adds nonzero (\p i, \p x) to SSVectorBase.
207  /** No nonzero with index \p i must exist in the SSVectorBase. */
208  void add(int i, R x)
209  {
210  assert(VectorBase<R>::val[i] == R(0));
211  assert(number(i) < 0);
212 
213  addIdx(i);
214  VectorBase<R>::val[i] = x;
215  }
216 
217  /// Sets \p i 'th element to \p x.
218  void setValue(int i, R x)
219  {
220  assert(i >= 0);
221  assert(i < DVectorBase<R>::dim());
222 
223  if( isSetup() )
224  {
225  int n = number(i);
226 
227  if( n < 0 )
228  {
229  if( spxAbs(x) > epsilon )
230  IdxSet::add(1, &i);
231  }
232  else if( x == R(0) )
233  clearNum(n);
234  }
235 
236  VectorBase<R>::val[i] = x;
237 
238  assert(isConsistent());
239  }
240 
241  /// Clears element \p i.
242  void clearIdx(int i)
243  {
244  if( isSetup() )
245  {
246  int n = number(i);
247 
248  if( n >= 0 )
249  remove(n);
250  }
251 
252  VectorBase<R>::val[i] = 0;
253 
254  assert(isConsistent());
255  }
256 
257  /// Sets \p n 'th nonzero element to 0 (index \p n must exist).
258  void clearNum(int n)
259  {
260  assert(isSetup());
261  assert(index(n) >= 0);
262 
263  VectorBase<R>::val[index(n)] = 0;
264  remove(n);
265 
266  assert(isConsistent());
267  }
268 
269  //@}
270 
271  // ------------------------------------------------------------------------------------------------------------------
272  /**@name Methods independent of the Status */
273  //@{
274 
275  /// Returns \p i 'th value.
276  R operator[](int i) const
277  {
278  return VectorBase<R>::val[i];
279  }
280 
281  /// Returns array indices.
282  const int* indexMem() const
283  {
284  return idx;
285  }
286 
287  /// Returns array values.
288  const R* values() const
289  {
290  return VectorBase<R>::val;
291  }
292 
293  /// Returns indices.
294  const IdxSet& indices() const
295  {
296  return *this;
297  }
298 
299  /// Returns array indices.
300  int* altIndexMem()
301  {
302  unSetup();
303  return idx;
304  }
305 
306  /// Returns array values.
308  {
309  unSetup();
310  return VectorBase<R>::val;
311  }
312 
313  /// Returns indices.
315  {
316  unSetup();
317  return *this;
318  }
319 
320  //@}
321 
322  // ------------------------------------------------------------------------------------------------------------------
323  /**@name Arithmetic operations */
324  //@{
325 
326  /// Addition.
327  template < class S >
329  {
331 
332  if (isSetup())
333  {
334  setupStatus = false;
335  setup();
336  }
337  return *this;
338  }
339 
340  /// Addition.
341  template < class S >
343 
344  /// Addition.
345  template < class S >
347  {
348  for( int i = vec.size() - 1; i >= 0; --i )
349  VectorBase<R>::val[vec.index(i)] += vec.value(i);
350 
351  if( isSetup() )
352  {
353  setupStatus = false;
354  setup();
355  }
356 
357  return *this;
358  }
359 
360  /// Subtraction.
361  template < class S >
363  {
365 
366  if( isSetup() )
367  {
368  setupStatus = false;
369  setup();
370  }
371 
372  return *this;
373  }
374 
375  /// Subtraction.
376  template < class S >
378 
379  /// Subtraction.
380  template < class S >
382  {
383  if( vec.isSetup() )
384  {
385  for( int i = vec.size() - 1; i >= 0; --i )
386  VectorBase<R>::val[vec.index(i)] -= vec.value(i);
387  }
388  else
390 
391  if( isSetup() )
392  {
393  setupStatus = false;
394  setup();
395  }
396 
397  return *this;
398  }
399 
400  /// Scaling.
401  template < class S >
403  {
404  assert(isSetup());
405  assert(x != S(0));
406 
407  for( int i = size() - 1; i >= 0; --i )
408  VectorBase<R>::val[index(i)] *= x;
409 
410  assert(isConsistent());
411 
412  return *this;
413  }
414 
415  // Inner product.
416  template < class S >
418  {
419  setup();
420 
421  R x = R(0);
422  int i = 0;
423  int j = 0;
424  int vi = index(i);
425  int wj = w.index(j);
426  int n = size();
427  int m = w.size();
428 
429  while( i < n && j < m )
430  {
431  if( vi == wj )
432  {
433  x += VectorBase<R>::val[vi] * R(w.val[wj]);
434  ++i;
435  ++j;
436  vi = index(i);
437  wj = w.index(j);
438  }
439  else if( vi < wj )
440  vi = index(++i);
441  else
442  wj = w.index(++j);
443  }
444 
445  return x;
446  }
447 
448  /// Addition of a scaled vector.
449  ///@todo SSVectorBase::multAdd() should be rewritten without pointer arithmetic.
450  template < class S, class T >
451  SSVectorBase<R>& multAdd(S xx, const SVectorBase<T>& vec);
452 
453  /// Addition of a scaled vector.
454  template < class S, class T >
456  {
457  VectorBase<R>::multAdd(x, vec);
458 
459  if( isSetup() )
460  {
461  setupStatus = false;
462  setup();
463  }
464 
465  return *this;
466  }
467 
468  /// Assigns \f$x^T \cdot A\f$ to SSVectorBase.
469  template < class S, class T >
471 
472  /// Assigns SSVectorBase to \f$A \cdot x\f$ for a setup \p x.
473  template < class S, class T >
475 
476 public:
477 
478  /// Assigns SSVectorBase to \f$A \cdot x\f$ thereby setting up \p x.
479  template < class S, class T >
481 
482  /// Maximum absolute value, i.e., infinity norm.
483  R maxAbs() const
484  {
485  if( isSetup() )
486  {
487  R maxabs = 0;
488 
489  for( int i = 0; i < num; ++i )
490  {
491  R x = spxAbs(VectorBase<R>::val[idx[i]]);
492 
493  if( x > maxabs )
494  maxabs = x;
495  }
496 
497  return maxabs;
498  }
499  else
500  return VectorBase<R>::maxAbs();
501  }
502 
503  /// Squared euclidian norm.
504  R length2() const
505  {
506  R x = 0;
507 
508  if( isSetup() )
509  {
510  for( int i = 0; i < num; ++i )
512  }
513  else
515 
516  return x;
517  }
518 
519  /// Floating point approximation of euclidian norm (without any approximation guarantee).
520  Real length() const
521  {
522  return spxSqrt((Real)length2());
523  }
524 
525  //@}
526 
527  // ------------------------------------------------------------------------------------------------------------------
528  /**@name Miscellaneous */
529  //@{
530 
531  /// Dimension of VectorBase.
532  int dim() const
533  {
534  return VectorBase<R>::dimen;
535  }
536 
537  /// Resets dimension to \p newdim.
538  void reDim(int newdim)
539  {
540  for( int i = IdxSet::size() - 1; i >= 0; --i )
541  {
542  if( index(i) >= newdim )
543  remove(i);
544  }
545 
546  DVectorBase<R>::reDim(newdim);
548 
549  assert(isConsistent());
550  }
551 
552  /// Sets number of nonzeros (thereby unSetup SSVectorBase).
553  void setSize(int n)
554  {
555  assert(n >= 0);
556  assert(n <= IdxSet::max());
557 
558  unSetup();
559  num = n;
560  }
561 
562  /// Resets memory consumption to \p newsize.
563  void reMem(int newsize)
564  {
565  DVectorBase<R>::reSize(newsize);
566  assert(isConsistent());
567 
569  }
570 
571  /// Clears vector.
572  void clear()
573  {
574  if( isSetup() )
575  {
576  for( int i = 0; i < num; ++i )
577  VectorBase<R>::val[idx[i]] = 0;
578  }
579  else
581 
582  IdxSet::clear();
583  setupStatus = true;
584 
585  assert(isConsistent());
586  }
587 
588  /// consistency check.
589  bool isConsistent() const
590  {
591 #ifdef ENABLE_CONSISTENCY_CHECKS
592  if( VectorBase<R>::dim() > IdxSet::max() )
593  return MSGinconsistent("SSVectorBase");
594 
595  if( VectorBase<R>::dim() < IdxSet::dim() )
596  return MSGinconsistent("SSVectorBase");
597 
598  if( isSetup() )
599  {
600  for( int i = 0; i < VectorBase<R>::dim(); ++i )
601  {
602  int j = number(i);
603 
604  if( j < 0 && spxAbs(VectorBase<R>::val[i]) > 0 )
605  {
606  MSG_ERROR( std::cerr << "ESSVEC01 i = " << i
607  << "\tidx = " << j
608  << "\tval = " << std::setprecision(16) << VectorBase<R>::val[i]
609  << std::endl; )
610 
611  return MSGinconsistent("SSVectorBase");
612  }
613  }
614  }
615 
617 #else
618  return true;
619 #endif
620  }
621 
622  //@}
623 
624  // ------------------------------------------------------------------------------------------------------------------
625  /**@name Constructors / Destructors */
626  //@{
627 
628  /// Default constructor.
629  explicit SSVectorBase<R>(int p_dim, R p_eps = Param::epsilon())
630  : DVectorBase<R>(p_dim)
631  , IdxSet()
632  , setupStatus(true)
633  , epsilon(p_eps)
634  {
635  len = (p_dim < 1) ? 1 : p_dim;
636  spx_alloc(idx, len);
638 
639  assert(isConsistent());
640  }
641 
642  /// Copy constructor.
643  template < class S >
645  : DVectorBase<R>(vec)
646  , IdxSet()
647  , setupStatus(vec.setupStatus)
648  , epsilon(vec.epsilon)
649  {
650  len = (vec.dim() < 1) ? 1 : vec.dim();
651  spx_alloc(idx, len);
652  IdxSet::operator=(vec);
653 
654  assert(isConsistent());
655  }
656 
657  /// Copy constructor.
658  /** The redundancy with the copy constructor below is necessary since otherwise the compiler doesn't realize that it
659  * could use the more general one with S = R and generates a shallow copy constructor.
660  */
662  : DVectorBase<R>(vec)
663  , IdxSet()
664  , setupStatus(vec.setupStatus)
665  , epsilon(vec.epsilon)
666  {
667  len = (vec.dim() < 1) ? 1 : vec.dim();
668  spx_alloc(idx, len);
669  IdxSet::operator=(vec);
670 
671  assert(isConsistent());
672  }
673 
674  /// Constructs nonsetup copy of \p vec.
675  template < class S >
676  explicit SSVectorBase<R>(const VectorBase<S>& vec, R eps = Param::epsilon())
677  : DVectorBase<R>(vec)
678  , IdxSet()
679  , setupStatus(false)
680  , epsilon(eps)
681  {
682  len = (vec.dim() < 1) ? 1 : vec.dim();
683  spx_alloc(idx, len);
684 
685  assert(isConsistent());
686  }
687 
688  /// Sets up \p rhs vector, and assigns it.
689  template < class S >
691  {
692  clear();
693  epsilon = rhs.epsilon;
694  setMax(rhs.max());
695  DVectorBase<R>::reDim(rhs.dim());
696 
697  if( rhs.isSetup() )
698  {
699  IdxSet::operator=(rhs);
700 
701  for( int i = size() - 1; i >= 0; --i )
702  {
703  int j = index(i);
704  VectorBase<R>::val[j] = rhs.val[j];
705  }
706  }
707  else
708  {
709  int d = rhs.dim();
710  num = 0;
711 
712  for( int i = 0; i < d; ++i )
713  {
714  if( rhs.val[i] != 0 )
715  {
716  if( spxAbs(rhs.val[i]) > epsilon )
717  {
718  rhs.idx[num] = i;
719  idx[num] = i;
720  VectorBase<R>::val[i] = rhs.val[i];
721  num++;
722  }
723  else
724  rhs.val[i] = 0;
725  }
726  }
727 
728  rhs.num = num;
729  rhs.setupStatus = true;
730  }
731 
732  setupStatus = true;
733 
734  assert(rhs.isConsistent());
735  assert(isConsistent());
736  }
737 
738  /// Assigns only the elements of \p rhs.
739  template < class S >
741 
742  /// Assignment operator.
743  template < class S >
745  {
746  assert(rhs.isConsistent());
747 
748  if( this != &rhs )
749  {
750  clear();
751  epsilon = rhs.epsilon;
752  setMax(rhs.max());
753  DVectorBase<R>::reDim(rhs.dim());
754 
755  if( rhs.isSetup() )
756  {
757  IdxSet::operator=(rhs);
758 
759  for( int i = size() - 1; i >= 0; --i )
760  {
761  int j = index(i);
762  VectorBase<R>::val[j] = rhs.val[j];
763  }
764  }
765  else
766  {
767  int d = rhs.dim();
768  num = 0;
769 
770  for( int i = 0; i < d; ++i )
771  {
772  if( spxAbs(rhs.val[i]) > epsilon )
773  {
774  VectorBase<R>::val[i] = rhs.val[i];
775  idx[num] = i;
776  num++;
777  }
778  }
779  }
780 
781  setupStatus = true;
782  }
783 
784  assert(isConsistent());
785 
786  return *this;
787  }
788 
789  /// Assignment operator.
791  {
792  assert(rhs.isConsistent());
793 
794  if( this != &rhs )
795  {
796  clear();
797  epsilon = rhs.epsilon;
798  setMax(rhs.max());
799  DVectorBase<R>::reDim(rhs.dim());
800 
801  if( rhs.isSetup() )
802  {
803  IdxSet::operator=(rhs);
804 
805  for( int i = size() - 1; i >= 0; --i )
806  {
807  int j = index(i);
808  VectorBase<R>::val[j] = rhs.val[j];
809  }
810  }
811  else
812  {
813  num = 0;
814 
815  for( int i = 0; i < rhs.dim(); ++i )
816  {
817  if( spxAbs(rhs.val[i]) > epsilon )
818  {
819  VectorBase<R>::val[i] = rhs.val[i];
820  idx[num] = i;
821  num++;
822  }
823  }
824  }
825 
826  setupStatus = true;
827  }
828 
829  assert(isConsistent());
830 
831  return *this;
832  }
833 
834  /// Assignment operator.
835  template < class S >
837 
838  /// Assignment operator.
839  template < class S >
841  {
842  unSetup();
844 
845  assert(isConsistent());
846 
847  return *this;
848  }
849 
850  /// destructor
852  {
853  if( idx )
854  spx_free(idx);
855  }
856 
857  //@}
858 
859 private:
860 
861  // ------------------------------------------------------------------------------------------------------------------
862  /**@name Private helpers */
863  //@{
864 
865  /// Assignment helper.
866  template < class S, class T >
868 
869  /// Assignment helper.
870  template < class S, class T >
872 
873  /// Assignment helper.
874  template < class S, class T >
876 
877  //@}
878 };
879 
880 } // namespace soplex
881 #endif // _SSVECTORBASE_H_
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:3925
void add(int n)
appends n uninitialized indices.
Definition: idxset.h:149
const R * values() const
Returns array values.
Definition: ssvectorbase.h:288
SSVectorBase< R > & assign2productFull(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assignment helper.
Definition: basevectors.h:717
int * idx
array of indices
Definition: idxset.h:65
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
VectorBase< R > & operator=(const VectorBase< S > &vec)
Assignment operator.
Definition: vectorbase.h:111
Memory allocation routines.
SSVectorBase< R > & assign(const SVectorBase< S > &rhs)
Assigns only the elements of rhs.
Definition: basevectors.h:818
Dynamic dense vectors.Class DVectorBase is a derived class of VectorBase adding automatic memory mana...
Definition: dvectorbase.h:48
Dense vector.Class VectorBase provides dense linear algebra vectors. It does not provide memory manag...
Definition: dsvectorbase.h:28
bool isConsistent() const
Consistency check.
Definition: dvectorbase.h:302
Set of indices.
SSVectorBase< R > & operator-=(const VectorBase< S > &vec)
Subtraction.
Definition: ssvectorbase.h:362
SSVectorBase< R > & operator+=(const SSVectorBase< S > &vec)
Addition.
Definition: ssvectorbase.h:346
SSVectorBase< R > & assign2product1(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assignment helper.
Definition: basevectors.h:571
Dynamic sparse vectors.Class DSVectorBase implements dynamic sparse vectors, i.e. SVectorBases with a...
Definition: dsvectorbase.h:42
void unSetup()
Makes SSVectorBase not setup.
Definition: ssvectorbase.h:126
void setValue(int i, R x)
Sets i &#39;th element to x.
Definition: ssvectorbase.h:218
void clear()
removes all indices.
Definition: idxset.h:184
SSVectorBase< R > & operator=(const SSVectorBase< R > &rhs)
Assignment operator.
Definition: ssvectorbase.h:790
bool isConsistent() const
consistency check.
Definition: ssvectorbase.h:589
int number(int i) const
Returns the position number of index i, or -1 if i doesn&#39;t exist.
Definition: ssvectorbase.h:191
void reMem(int newsize)
Resets memory consumption to newsize.
Definition: ssvectorbase.h:563
SSVectorBase< R > & operator*=(S x)
Scaling.
Definition: ssvectorbase.h:402
IdxSet()
default constructor.
Definition: idxset.h:91
SSVectorBase< R > & multAdd(S x, const VectorBase< T > &vec)
Addition of a scaled vector.
Definition: ssvectorbase.h:455
R operator*(const SSVectorBase< S > &w)
Definition: ssvectorbase.h:417
int * altIndexMem()
Returns array indices.
Definition: ssvectorbase.h:300
bool setupStatus
Is the SSVectorBase set up?
Definition: ssvectorbase.h:59
VectorBase< R > & operator+=(const VectorBase< S > &vec)
Addition.
Definition: vectorbase.h:230
void addIdx(int i)
appends index i.
Definition: idxset.h:165
Semi sparse vector.This class implements semi-sparse vectors. Such are DVectorBases where the indices...
Definition: dsvectorbase.h:29
int index(int n) const
access n &#39;th index.
Definition: idxset.h:118
SSVectorBase< R > & assign2productAndSetup(const SVSetBase< S > &A, SSVectorBase< T > &x)
Assigns SSVectorBase to thereby setting up x.
Definition: basevectors.h:760
void spx_alloc(T &p, int n=1)
Allocate memory.
Definition: spxalloc.h:48
R * altValues()
Returns array values.
Definition: ssvectorbase.h:307
R * get_ptr()
Conversion to C-style pointer.
Definition: vectorbase.h:403
void reSize(int newsize)
Resets DVectorBase&#39;s memory size to newsize.
Definition: dvectorbase.h:266
int dim() const
Dimension of the vector defined as maximal index + 1.
Definition: svectorbase.h:166
double Real
SOPLEX_DEBUG.
Definition: spxdefines.h:200
int index(int n) const
Returns index of the n &#39;th nonzero element.
Definition: ssvectorbase.h:174
int number(int i) const
returns the position number of index i.
Definition: idxset.cpp:32
SSVectorBase< R > & assign2product(const SSVectorBase< S > &x, const SVSetBase< T > &A)
Assigns to SSVectorBase.
Definition: basevectors.h:507
bool isConsistent() const
consistency check.
Definition: idxset.cpp:113
int len
length of array idx
Definition: idxset.h:64
int size() const
returns the number of used indices.
Definition: idxset.h:124
void clearNum(int n)
Sets n &#39;th nonzero element to 0 (index n must exist).
Definition: ssvectorbase.h:258
IdxSet & operator=(const IdxSet &set)
assignment operator.
Definition: idxset.cpp:68
int max() const
returns the maximal number of indices which can be stored in IdxSet.
Definition: idxset.h:129
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
Definition: spxdefines.h:109
Real spxSqrt(Real a)
returns square root
Definition: spxdefines.h:325
void clear()
Clears vector.
Definition: ssvectorbase.h:572
IdxSet & altIndices()
Returns indices.
Definition: ssvectorbase.h:314
R * val
Values of vector.
Definition: vectorbase.h:87
void setEpsilon(R eps)
Changes the non-zero epsilon, invalidating the setup. */.
Definition: ssvectorbase.h:110
SSVectorBase< R > & multAdd(S xx, const SVectorBase< T > &vec)
Addition of a scaled vector.
Definition: basevectors.h:440
Real length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
Definition: ssvectorbase.h:520
SSVectorBase< R > & operator-=(const SSVectorBase< S > &vec)
Subtraction.
Definition: ssvectorbase.h:381
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
Definition: vectorbase.h:314
void reDim(int newdim)
Resets dimension to newdim.
Definition: ssvectorbase.h:538
Debugging, floating point type and parameter definitions.
bool isSetup() const
Returns setup status.
Definition: ssvectorbase.h:120
void setSize(int n)
Sets number of nonzeros (thereby unSetup SSVectorBase).
Definition: ssvectorbase.h:553
void clearIdx(int i)
Clears element i.
Definition: ssvectorbase.h:242
R * get_ptr()
Only used in slufactor.cpp.
Definition: ssvectorbase.h:99
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Definition: spxalloc.h:79
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
Definition: vectorbase.h:369
void setup_and_assign(SSVectorBase< S > &rhs)
Sets up rhs vector, and assigns it.
Definition: ssvectorbase.h:690
Everything should be within this namespace.
int dim() const
returns the maximal index.
Definition: idxset.cpp:21
void setMax(int newmax)
Allocates enough space to accommodate newmax values.
Definition: ssvectorbase.h:65
SSVectorBase< R > & operator=(const SSVectorBase< S > &rhs)
Assignment operator.
Definition: ssvectorbase.h:744
const IdxSet & indices() const
Returns indices.
Definition: ssvectorbase.h:294
SSVectorBase< R > & operator+=(const VectorBase< S > &vec)
Addition.
Definition: ssvectorbase.h:328
VectorBase< R > & operator-=(const VectorBase< S > &vec)
Subtraction.
Definition: vectorbase.h:251
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
Definition: ssvectorbase.h:483
void setup()
Initializes nonzero indices for elements with absolute values above epsilon and sets all other elemen...
Definition: ssvectorbase.h:132
void clear()
Set vector to 0.
Definition: vectorbase.h:219
void forceSetup()
Forces setup status.
Definition: ssvectorbase.h:162
SSVectorBase< R > & operator=(const VectorBase< S > &rhs)
Assignment operator.
Definition: ssvectorbase.h:840
R length2() const
Squared euclidian norm.
Definition: ssvectorbase.h:504
int dim() const
Dimension of VectorBase.
Definition: ssvectorbase.h:532
R getEpsilon() const
Returns the non-zero epsilon used.
Definition: ssvectorbase.h:104
const int * indexMem() const
Returns array indices.
Definition: ssvectorbase.h:282
Sparse vectors.Class SVectorBase provides packed sparse vectors. Such are a sparse vectors...
Definition: dvectorbase.h:31
#define MSGinconsistent(name)
Definition: spxdefines.h:121
R epsilon
A value x with |x| < epsilon is considered zero.
Definition: ssvectorbase.h:62
int num
number of used indices
Definition: idxset.h:63
R value(int n) const
Returns value of the n &#39;th nonzero element.
Definition: ssvectorbase.h:182
void add(int i, R x)
Adds nonzero (i, x) to SSVectorBase.
Definition: ssvectorbase.h:208
SSVectorBase< R > & assign2productShort(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assignment helper.
Definition: basevectors.h:606
static Real epsilon()
Definition: spxdefines.h:255
R operator[](int i) const
Returns i &#39;th value.
Definition: ssvectorbase.h:276
Set of indices.Class IdxSet provides a set of indices. At construction it must be given an array of i...
Definition: idxset.h:56
void spx_free(T &p)
Release memory.
Definition: spxalloc.h:109
Sparse vector set.Class SVSetBase provides a set of sparse vectors SVectorBase. All SVectorBases in a...
Definition: ssvectorbase.h:33
int size() const
Returns the number of nonzeros.
Definition: ssvectorbase.h:199
Dynamic dense vectors.
R length2() const
Squared norm.
Definition: vectorbase.h:362
SSVectorBase< R > & assign2product4setup(const SVSetBase< S > &A, const SSVectorBase< T > &x)
Assigns SSVectorBase to for a setup x.
Definition: basevectors.h:538