hyb_parameter.h
Go to the documentation of this file.
1/** @file hyb_parameter.h Parameter types for linear hybrid automata */
2
3
4/*
5 Hybrid systems plug-in for FAU Discrete Event Systems Library
6
7 Copyright (C) 2010 Thomas Moor
8
9*/
10
11#ifndef FAUDES_HYB_PARAMETER_H
12#define FAUDES_HYB_PARAMETER_H
13
14#include "corefaudes.h"
15#include <cstdlib>
16#include <cstring>
17#include <cfloat>
18#include <climits>
19
20
21namespace faudes {
22
23/**
24 * Base type for dense maths.
25 *
26 * The hybrid systems plug-in refers to scalar parameters to represent
27 * states, constraints, guards and time. The current implementaion uses
28 * the floating point representation by the C type "double". As an
29 * alternative, one could consider arbitrary preciscion arithmetic.
30 *
31 *
32 * @ingroup HybridPlugin
33 */
35 public:
36 /** Datatype for scalar */
37 typedef double Type;
38};
39
40
41/**
42 *
43 * Matrix of scalars.
44 *
45 * This is a wrapper for a plain C array to provide a faudes style
46 * interface, incl. token IO, access to individual entries. There is also
47 * access to the internal C++ array. Note that libFAUDES does not implement
48 * any mathematical operations on matrices. For this purpose, one should employ
49 * some external library (e.g. BOOST, alglib, ...) via
50 * an appropriate set of wrapper functions.
51 *
52 * The token format is
53 * as follows:
54 *
55 * @code
56 * <Matrix rows="2" columns="5">
57 * 1.50 -80 17 90 100
58 * 5.23 23 2 -5 13
59 * </Matrix>
60 * @endcode
61 *
62 * @ingroup HybridPlugin
63 */
64class FAUDES_API Matrix : public Type {
65
67
68public:
69
70
71
72 /**
73 * Default constructor - sets dimension to 0x0
74 */
75 Matrix(void);
76
77 /**
78 * Constructor by dimension
79 *
80 * @param rc
81 * row count
82 * @param cc
83 * column count
84 *
85 */
86 Matrix(int rc, int cc);
87
88 /**
89 * Copy-constructor
90 */
91 Matrix(const Matrix& rSrc);
92
93 /**
94 * Construct from file
95 */
96 Matrix(const std::string& rFileName);
97
98
99 /**
100 * Destructor
101 */
102 virtual ~Matrix(void);
103
104
105 /**
106 * Clear all.
107 *
108 * Sets row- and column count to 0;
109 *
110 */
111 void Clear(void);
112
113 /**
114 * Get size.
115 *
116 * Gets over all number of entries.
117 *
118 * @return
119 * RowCount() * ColumnCount()
120 */
121 Idx Size(void) const;
122
123
124 /**
125 * Set dimension.
126 *
127 * This will invalidate the entries.
128 *
129 * @param rc
130 * row count
131 */
132 void RowCount(int rc);
133
134 /**
135 * Get Dimension.
136 *
137 * Set number of rows and invalidate all entries.
138 *
139 * @return
140 * row count
141 */
142 int RowCount(void) const;
143
144 /**
145 * Set Dimension.
146 *
147 * Set number of columns and invalidate all entries.
148 *
149 * @param cc
150 * column count
151 */
152 void ColumnCount(int cc);
153
154 /**
155 * Get Dimension.
156 *
157 * @return
158 * column count
159 */
160 int ColumnCount(void) const;
161
162 /**
163 * Set Dimension.
164 *
165 * Set dimensions and invalidate all entries.
166 *
167 * @param rc
168 * row count
169 * @param cc
170 * column count
171 */
172 void Dimension(int rc, int cc);
173
174 /**
175 * Set to zero matrix.
176 *
177 * Either provide dimensions, or use the
178 * default -1 to maintain dimensions.
179 *
180 * @param rc
181 * row count
182 * @param cc
183 * column count
184 */
185 void Zero(int rc=-1, int cc=-1);
186
187 /**
188 * Set to identity matrix.
189 *
190 * Either provide dimensions, or use the
191 * default -1 to maintain dimensions.
192 *
193 * @param dim
194 * row and comlumn count
195 */
196 void Identity(int dim=-1);
197
198 /**
199 * Get entry.
200 *
201 * @param i
202 * row index.
203 * @param j
204 * column index.
205 *
206 * @return
207 * entry A(i,j)
208 * @exception Exception
209 * - index out of range (id 700);
210 *
211 */
212 const Scalar::Type& At(int i, int j) const;
213
214 /**
215 * Set entry.
216 *
217 * @param i
218 * row index.
219 * @param j
220 * column index.
221 * @param val
222 * new value
223 *
224 * @exception Exception
225 * - index out of range (id 700);
226 *
227 */
228 void At(int i, int j, const Scalar::Type& val);
229
230 /**
231 * Cosmetic access operator.
232 *
233 * @param i
234 * row index.
235 * @param j
236 * column index.
237 *
238 * @exception Exception
239 * - index out of range (id 700);
240 *
241 */
242 const Scalar::Type& operator()(int i, int j) const;
243
244 /**
245 * Cosmetic access operator.
246 *
247 * @param i
248 * row index.
249 * @param j
250 * column index.
251 *
252 * @exception Exception
253 * - index out of range (id 700);
254 *
255 */
256 Scalar::Type& operator()(int i, int j);
257
258
259 /**
260 * Set from std C array.
261 *
262 * The provided data must be organized as
263 * A(i,j)=data[i*cc+j]. This version takes a
264 * copy of the provided data.
265 *
266 * @param rc
267 * row count
268 * @param cc
269 * column count
270 * @param data
271 * pointer to C array of entries.
272 */
273 void CArray(int rc, int cc, const Scalar::Type *data);
274
275 /**
276 * Access std C array.
277 *
278 * The data field is organized as
279 * A(i,j)=data[i*column_count+j]. Note that
280 * for zero row- or column count, this function returns
281 * NULL.
282 *
283 * @return
284 * const pointer to internal C array
285 *
286 */
287 const Scalar::Type* CArray(void) const;
288
289 protected:
290
291 /* Matrix: dimensions */
292 int mRC;
293 int mCC;
294
295 /* Matrix: data */
297
298 /**
299 * Copy from other matrix.
300 *
301 * @param rSrc
302 * source to copy from
303 * @return
304 * ref to this matrix
305 */
306 virtual Matrix& DoCopy(const Matrix& rSrc);
307
308
309 /**
310 * Test equality.
311 *
312 * @param rOther
313 * Other object to compare with.
314 * @return
315 * True on match.
316 */
317 virtual bool DoEqual(const Matrix& rOther) const;
318
319 /**
320 * Write to TokenWriter, see Type::Write for public wrappers
321 *
322 * @param tw
323 * Reference to TokenWriter
324 * @param rLabel
325 * Label of the section to write, defaults to name of set or "Matrix"
326 * @param pContext
327 * Write context to provide contextual information (ignores)
328 *
329 * @exception Exception
330 * - IO errors (id 2)
331 */
332 virtual void DoWrite(TokenWriter& tw, const std::string& rLabel="", const Type* pContext=0) const;
333
334 /** Write statistic info to TokenWriter, see Type::SWrite for public wrapper.
335 *
336 * @param tw
337 * Reference to TokenWriter
338 * @exception Exception
339 * - IO errors (id 2)
340 */
341 virtual void DoSWrite(TokenWriter& tw) const;
342
343 /**
344 * Read from TokenReader, see Type::Read for public wrappers.
345 * The method invokes TokenReader::ReadBegin() to seek the specified
346 * section, reads subsequent symbols, and calls matching TokenReader::ReadEnd().
347 * If no section is specified, the section is assumed to start at the current position
348 * of the token stream. If the current position is no begin token,
349 * the section "Matrix" is read.
350 *
351 * @param tr
352 * Reference to TokenReader
353 * @param rLabel
354 * Label to read, defaults to current begin label or else "Matrix"
355 * @param pContext
356 * Write context to provide contextual information
357 *
358 * @exception Exception
359 * - IO errors (id 1)
360 * - token mismatch (id 50)
361 */
362 virtual void DoRead(TokenReader& tr, const std::string& rLabel = "", const Type* pContext=0);
363
364};
365
366
367
368
369/**
370 *
371 * Vector of scalars.
372 *
373 * This is a wrapper for a plain C array to provide a faudes style
374 * interface, incl. token IO, access to individual entries. There is also
375 * access to the internal C++ array. Note that libFAUDES does not implement
376 * any mathematical operations on vectors. For this purpose, one should employ
377 * some external library (e.g. BOOST, alglib, ...) via
378 * an appropriate set of wrapper functions.
379 *
380 * The token format is
381 * as follows:
382 *
383 * @code
384 * <Vector count="5">
385 * 1.50 -80 17 90 100
386 * </Vector>
387 * @endcode
388 *
389 * @ingroup HybridPlugin
390 */
391class FAUDES_API Vector : public Type {
392
394
395public:
396
397
398
399 /**
400 * Default constructor - sets dimension to 0
401 */
402 Vector(void);
403
404 /**
405 * Constructor by dimension
406 *
407 * @param dim
408 * dimension
409 *
410 */
411 Vector(int dim);
412
413 /**
414 * Copy-constructor
415 */
416 Vector(const Vector& rSrc);
417
418 /**
419 * Construct from file
420 */
421 Vector(const std::string& rFileName);
422
423
424 /**
425 * Destructor
426 */
427 virtual ~Vector(void);
428
429
430 /**
431 * Clear all.
432 *
433 * Sets dimension to 0
434 *
435 */
436 void Clear(void);
437
438 /**
439 * Get size.
440 *
441 * Gets over all number of entries. Same as Dimension().
442 *
443 * @return
444 * Dimension()
445 */
446 Idx Size(void) const;
447
448
449 /**
450 * Get dimension.
451 *
452 * @return
453 * Number of entries
454 */
455 int Dimension(void) const;
456
457 /**
458 * Set dimension.
459 *
460 * This will invalidate the entries.
461 *
462 * @param dim
463 * New dimension
464 */
465 void Dimension(int dim);
466
467 /**
468 * Set to zero vector.
469 *
470 * Either provide dimension, or use the
471 * default -1 to maintain the dimension.
472 *
473 * @param dim
474 * number of entries
475 */
476 void Zero(int dim=-1);
477
478 /**
479 * Set to ones.
480 *
481 * Either provide dimension, or use the
482 * default -1 to maintain the dimension.
483 *
484 * @param dim
485 * number of entries
486 */
487 void Ones(int dim=-1);
488
489 /**
490 * Get entry.
491 *
492 * @param i
493 * index.
494 * @return
495 * entry V(i)
496 * @exception Exception
497 * - index out of range (id 700);
498 *
499 */
500 const Scalar::Type& At(int i) const;
501
502 /**
503 * Set entry.
504 *
505 * @param i
506 * index
507 * @param val
508 * value
509 *
510 * @exception Exception
511 * - index out of range (id 700);
512 *
513 */
514 void At(int i, const Scalar::Type& val);
515
516 /**
517 * Cosmetic access operator.
518 *
519 * @param i
520 * index.
521 *
522 * @exception Exception
523 * - index out of range (id 700);
524 */
525 const Scalar::Type& operator()(int i) const;
526
527 /**
528 * Cosmetic access operator.
529 *
530 * @param i
531 * index.
532 * @exception Exception
533 * - index out of range (id 700);
534 */
535 Scalar::Type& operator()(int i);
536
537 /**
538 * Set from std C array.
539 *
540 * This version takes a
541 * copy of the provided data.
542 *
543 * @param dim
544 * dimension
545 * @param data
546 * pointer to array of entries.
547 */
548 void CArray(int dim, const Scalar::Type *data);
549
550 /**
551 * Access std C array.
552 *
553 * Note that for zero dimension, this function returns
554 * NULL.
555 *
556 * @return
557 * Const ref to internal C array
558 *
559 */
560 const Scalar::Type* CArray(void) const;
561
562
563 protected:
564
565 /* Vector: dimensions */
566 int mDim;
567
568 /* Vector: data */
570
571 /**
572 * Copy from other vector
573 *
574 * @param rSrc
575 * Source to copy from
576 * @return
577 * Ref to this vector
578 */
579 virtual Vector& DoCopy(const Vector& rSrc);
580
581
582 /**
583 * Test equality.
584 *
585 * @param rOther
586 * Other object to compare with.
587 * @return
588 * True on match.
589 */
590 virtual bool DoEqual(const Vector& rOther) const;
591
592 /**
593 * Write to TokenWriter, see Type::Write for public wrappers
594 *
595 * @param tw
596 * Reference to TokenWriter
597 * @param rLabel
598 * Label of the section to write, defaults to name of set or "Vector"
599 * @param pContext
600 * Write context to provide contextual information (ignores)
601 *
602 * @exception Exception
603 * - IO errors (id 2)
604 */
605 virtual void DoWrite(TokenWriter& tw, const std::string& rLabel="", const Type* pContext=0) const;
606
607 /** Write statistic info to TokenWriter, see Type::SWrite for public wrapper.
608 *
609 * @param tw
610 * Reference to TokenWriter
611 * @exception Exception
612 * - IO errors (id 2)
613 */
614 virtual void DoSWrite(TokenWriter& tw) const;
615
616 /**
617 * Read from TokenReader, see Type::Read for public wrappers.
618 * The method invokes TokenReader::ReadBegin() to seek the specified
619 * section, reads subsequent symbols, and calls matching TokenReader::ReadEnd().
620 * If no section is specified, the section is assumed to start at the current position
621 * of the token stream. If the current position is no begin token,
622 * the section "Vector" is read.
623 *
624 * @param tr
625 * Reference to TokenReader
626 * @param rLabel
627 * Label to read, defaults to current begin label or else "Vector"
628 * @param pContext
629 * Write context to provide contextual information
630 *
631 * @exception Exception
632 * - IO errors (id 1)
633 * - token mismatch (id 50)
634 */
635 virtual void DoRead(TokenReader& tr, const std::string& rLabel = "", const Type* pContext=0);
636
637};
638
639
640
641/**
642 *
643 * Polyhedron in R^n
644 *
645 * This class is a container to hold a matrix A and a vector B to represent
646 * the polyhedron {x| Ax<=b}. It provides basic member access and token IO.
647 *
648 * To facilitate the ussage of an external library (e.g. PPL) that implements
649 * operations on polyhedra, the Polyhedron container can record untyped user
650 * data in a (void*) entry. See hyb_compute.cpp for a PLL based implemenation
651 * of a reachability analysis.
652 *
653 * The token format is as follows:
654 *
655 * @code
656 * <Polyhedron>
657 * <AMatrix rows="4" columns="2">
658 * 1 0
659 * -1 0
660 * 0 1
661 * 0 -1
662 * </AMatrix>
663 * <BVector count="4">
664 * 1
665 * 0
666 * 1
667 * 0
668 * </BVector>
669 * </Polyhedron>
670 * @endcode
671 *
672 * @ingroup HybridPlugin y
673 */
674class FAUDES_API Polyhedron : public Type {
675
677
678public:
679
680
681
682 /**
683 * Default constructor - sets dimension to 0
684 */
685 Polyhedron(void);
686
687 /**
688 * Constructor by dimension
689 *
690 * @param dim
691 * dimension
692 *
693 */
694 Polyhedron(int dim);
695
696 /**
697 * Copy-constructor
698 */
699 Polyhedron(const Polyhedron& rSrc);
700
701 /**
702 * Construct from file
703 */
704 Polyhedron(const std::string& rFileName);
705
706
707 /**
708 * Destructor
709 */
710 virtual ~Polyhedron(void);
711
712 /**
713 * Object name
714 *
715 * @return name
716 */
717 virtual const std::string& Name(void) const {return mName;};
718
719 /**
720 * Object name
721 *
722 * @param name
723 * Set to specifies name
724 */
725 virtual void Name(const std::string& name) {mName=name;};
726
727
728 /**
729 * Clear all.
730 *
731 * Sets dimension to 0
732 *
733 */
734 void Clear(void);
735
736 /**
737 * Get size.
738 *
739 * Gets the number of inequalities (number of rows of A).
740 *
741 * @return
742 * number of equations
743 */
744 Idx Size(void) const;
745
746
747 /**
748 * Get dimension.
749 * Gets the dimension of the polyhedron (number of columns of A).
750 *
751 * @return
752 * dimension
753 */
754 int Dimension(void) const;
755
756 /**
757 * Set dimension.
758 *
759 * This will invalidate A and B.
760 *
761 * @param dim
762 * New dimension
763 */
764 void Dimension(int dim);
765
766 /**
767 * Get A matrix.
768 *
769 */
770 const Matrix& A(void) const;
771
772 /**
773 * Get B vector.
774 *
775 */
776 const Vector& B(void) const;
777
778 /**
779 * Set A matrix and B vector.
780 *
781 * @param rA
782 * A matrix
783 * @param rB
784 * B vector
785 *
786 * @exception Exception
787 * - dimension missmatch (id 700);
788 *
789 */
790 void AB(const Matrix& rA, const Vector& rB);
791
792 /**
793 * Set user data.
794 *
795 * The polyhedron takes ownership of
796 * the provided memory. On write access on the
797 * defining parameters, the user data gets
798 * invalidated by means of "delete". The internal pointer
799 * is then set to NULL.
800 *
801 */
802 void UserData(Type* data) const;
803
804 /**
805 * Get user data.
806 *
807 * @return
808 * Pointer to user data, or NULL if no valid data is available
809 *
810 */
811 Type* UserData(void) const;
812
813
814 protected:
815
816
817 /** name */
818 std::string mName;
819
820 /** Polyhedron: data */
822
823 /** Polyhedron: data */
825
826 /** User data */
828
829 /**
830 * Copy from other polyhedron
831 *
832 * @param rSrc
833 * Source to copy from
834 * @return
835 * Ref to this polyhedron
836 */
837 virtual Polyhedron& DoCopy(const Polyhedron& rSrc);
838
839
840 /**
841 * Test equality.
842 *
843 * Note: this test refers to the plain parameters as oposed to the
844 * actual polyhedron.
845 *
846 * @param rOther
847 * Other object to compare with.
848 * @return
849 * True on match.
850 */
851 virtual bool DoEqual(const Polyhedron& rOther) const;
852
853 /**
854 * Write to TokenWriter, see Type::Write for public wrappers
855 *
856 * @param tw
857 * Reference to TokenWriter
858 * @param rLabel
859 * Label of the section to write, defaults to name of set or "Polyhedron"
860 * @param pContext
861 * Write context to provide contextual information (ignores)
862 *
863 * @exception Exception
864 * - IO errors (id 2)
865 */
866 virtual void DoWrite(TokenWriter& tw, const std::string& rLabel="", const Type* pContext=0) const;
867
868 /** Write statistic info to TokenWriter, see Type::SWrite for public wrapper.
869 *
870 * @param tw
871 * Reference to TokenWriter
872 *
873 * @exception Exception
874 * - IO errors (id 2)
875 */
876 virtual void DoSWrite(TokenWriter& tw) const;
877
878 /**
879 * Read from TokenReader, see Type::Read for public wrappers.
880 * The method invokes TokenReader::ReadBegin() to seek the specified
881 * section, reads subsequent symbols, and calls matching TokenReader::ReadEnd().
882 * If no section is specified, the section is assumed to start at the current position
883 * of the token stream. If the current position is no begin token,
884 * the section "Polyhedron" is read.
885 *
886 * @param tr
887 * Reference to TokenReader
888 * @param rLabel
889 * Label to read, defaults to current begin label or else "Polyhedron"
890 * @param pContext
891 * Write context to provide contextual information
892 *
893 * @exception Exception
894 * - IO errors (id 1)
895 * - token mismatch (id 50)
896 */
897 virtual void DoRead(TokenReader& tr, const std::string& rLabel = "", const Type* pContext=0);
898
899
900
901
902};
903
904
905/**
906 *
907 * Linear relation on R^n
908 *
909 * This class is a container to hold matrices A1 and A2 and a vector B to represent
910 * the relation
911 *
912 * {(x1,x2) | A1 x1 + A2 x2 <= B}.
913 *
914 * Effectively, a linear relation on R^n is a polyhedron on R^(2n).
915 * For an alternative parametrisation for a linear relation consider an affine map "x -> C x + d" and a
916 * subsequent bloat by a polyhedral offset "F x <= E", to obtain:
917 *
918 * {(x1,x2) | F ( x2 - (C x1 + D) ) <= E}.
919 *
920 * to convert the second from to the first, we have the correspondence
921 *
922 * A1 = -F C; A2 = F; B = E + F D ;
923 *
924 * The class maintains a flags to indicate the special cases {(x1,x2) | x2 = C x1 + D }
925 * and {(x1,x2) | x2 = x1 }. These flags, however, are purely syntatic, i.e., they need
926 * to be set by using the respective initialisers.
927 *
928 * To facilitate the ussage of an external library that implements transformations
929 * on polyhedra, the Relation container can record untyped user data in a (void*) entry.
930 * See hyb_compute.cpp for a PLL based implemenation of a reachability analysis.
931 *
932 * The token format is
933 * as follows:
934 *
935 * @code
936 * % general relation
937 * <Relation>
938 * <A1Matrix>
939 * ...
940 * </A1Matrix>
941 * <A2Matrix>
942 * ...
943 * </A2Matrix>
944 * <BVector>
945 * ...
946 * </BVector>
947 * </Relation>
948 * @endcode
949 *
950 *
951 * @code
952 * % affine map
953 * <Relation>
954 * <CMatrix>
955 * ...
956 * </CMatrix>
957 * <DVector>
958 * ...
959 * </DVector>
960 * </Relation>
961 * @endcode
962 *
963 * @code
964 * % identity
965 * <Relation dimension="2"/>
966 * @endcode
967 *
968 * @ingroup HybridPlugin
969 */
971
973
974public:
975
976 /**
977 * Default constructor.
978 * Sets dimension to 0 and the relation to be the identity map.
979 */
980 LinearRelation(void);
981
982 /**
983 * Constructor by dimension.
984 * Sets the relation to be the identity map.
985 *
986 * @param dim
987 * Dimension
988 *
989 */
990 LinearRelation(int dim);
991
992 /**
993 * Copy-constructor
994 */
995 LinearRelation(const LinearRelation& rSrc);
996
997 /**
998 * Construct from file
999 */
1000 LinearRelation(const std::string& rFileName);
1001
1002
1003 /**
1004 * Destructor
1005 */
1006 virtual ~LinearRelation(void);
1007
1008
1009 /**
1010 * Object name
1011 *
1012 * @return name
1013 */
1014 virtual const std::string& Name(void) const {return mName;};
1015
1016 /**
1017 * Object name
1018 *
1019 * @param name
1020 * Set to specifies name
1021 */
1022 virtual void Name(const std::string& name) {mName=name;};
1023
1024 /**
1025 * Clear all.
1026 *
1027 * Sets dimension to 0 with identity
1028 *
1029 */
1030 void Clear(void);
1031
1032 /**
1033 * Get size.
1034 *
1035 * Number of inequalities.
1036 *
1037 * @return
1038 * Eq count
1039 */
1040 Idx Size(void) const;
1041
1042
1043 /**
1044 * Get dimension.
1045 *
1046 * @return
1047 * Dimension
1048 */
1049 int Dimension(void) const;
1050
1051 /**
1052 * Set dimension.
1053 *
1054 * Defaults to identity map.
1055 *
1056 * @param dim
1057 * New dimension
1058 */
1059 void Dimension(int dim);
1060
1061
1062 /**
1063 * Test for data format.
1064 *
1065 * The current implementation allway sets up the matrices
1066 * A1, A2 and B and, hence, allways returns true.
1067 */
1068 bool Relation(void) const;
1069
1070
1071 /**
1072 * Test for data format.
1073 * True when initialsed via Map or Identity. When initialised by
1074 * Relation, the map data format is not available.
1075 */
1076 bool Map(void) const;
1077
1078 /**
1079 * Test for data format.
1080 * True only if initialsed Identity.
1081 *
1082 */
1083 bool Identity(void) const;
1084
1085
1086
1087 /**
1088 * Get A1 matrix.
1089 *
1090 */
1091 const Matrix& A1(void) const;
1092
1093 /**
1094 * Get A2 matrix.
1095 *
1096 */
1097 const Matrix& A2(void) const;
1098
1099 /**
1100 * Get B vector.
1101 *
1102 */
1103 const Vector& B(void) const;
1104
1105 /**
1106 * Get C matrix.
1107 *
1108 * Note: this is only defined for the cases Map and Identity.
1109 *
1110 */
1111 const Matrix& C(void) const;
1112
1113 /**
1114 * Get D vector.
1115 *
1116 * Note: this is only defined for the cases Map and Identity.
1117 */
1118 const Vector& D(void) const;
1119
1120 /**
1121 * Set by A1, A2 and B
1122 *
1123 * @param rA1
1124 * A1 matrix
1125 * @param rA2
1126 * A2 matrix
1127 * @param rB
1128 * B vector
1129 *
1130 * @exception Exception
1131 * - dimension missmatch (id 700);
1132 *
1133 */
1134 void Relation(const Matrix& rA1, const Matrix& rA2, const Vector& rB);
1135
1136 /**
1137 * Set to affine map Cx+D
1138 *
1139 * @param rC
1140 * C matrix
1141 * @param rB
1142 * D vector
1143 *
1144 * @exception Exception
1145 * - dimension missmatch (id 700);
1146 *
1147 */
1148 void Map(const Matrix& rC, const Vector& rD);
1149
1150 /**
1151 * Set to identity
1152 *
1153 * @param dim
1154 * dimension
1155 */
1156 void Identity(int dim);
1157
1158
1159 /**
1160 * Set user data.
1161 *
1162 * The relation takes ownership of
1163 * the provided memory. On write access on the
1164 * defining parameters the user data gets
1165 * invalidated by means of "delete". The internal pointer
1166 * is then set to NULL.
1167 *
1168 */
1169 void UserData(Type* data) const;
1170
1171 /**
1172 * Get user data.
1173 *
1174 * @return
1175 * Pointer to user data, or NULL if no internal data available
1176 *
1177 */
1178 Type* UserData(void) const;
1179
1180 protected:
1181
1182 /** have a name */
1183 std::string mName;
1184
1185 /** Case enum */
1186 typedef enum{R,M,I} TCase;
1187
1188 /** Case flag */
1190
1191 /** LinearRelation: data */
1197
1198 /** User data */
1200
1201 /**
1202 * Copy from other polyhedron
1203 *
1204 * @param rSrc
1205 * Source to copy from
1206 * @return
1207 * Ref to this polyhedron
1208 */
1209 virtual LinearRelation& DoCopy(const LinearRelation& rSrc);
1210
1211
1212 /**
1213 * Test equality.
1214 *
1215 * Note: this test refers to the paramtrisation as oposed to the
1216 * actual relation.
1217 *
1218 * @param rOther
1219 * Other object to compare with.
1220 * @return
1221 * True on match.
1222 */
1223 virtual bool DoEqual(const LinearRelation& rOther) const;
1224
1225 /**
1226 * Write to TokenWriter, see Type::Write for public wrappers
1227 *
1228 * @param tw
1229 * Reference to TokenWriter
1230 * @param rLabel
1231 * Label of the section to write, defaults to name of set or "LinearRelation"
1232 * @param pContext
1233 * Write context to provide contextual information (ignores)
1234 *
1235 * @exception Exception
1236 * - IO errors (id 2)
1237 */
1238 virtual void DoWrite(TokenWriter& tw, const std::string& rLabel="", const Type* pContext=0) const;
1239
1240 /** Write statistic info to TokenWriter, see Type::SWrite for public wrapper.
1241 *
1242 * @param tw
1243 * Reference to TokenWriter
1244 *
1245 * @exception Exception
1246 * - IO errors (id 2)
1247 */
1248 virtual void DoSWrite(TokenWriter& tw) const;
1249
1250 /**
1251 * Read from TokenReader, see Type::Read for public wrappers.
1252 * The method invokes TokenReader::ReadBegin() to seek the specified
1253 * section, reads subsequent symbols, and calls matching TokenReader::ReadEnd().
1254 * If no section is specified, the section is assumed to start at the current position
1255 * of the token stream. If the current position is no begin token,
1256 * the section "LinearRelation" is read.
1257 *
1258 * @param tr
1259 * Reference to TokenReader
1260 * @param rLabel
1261 * Label to read, defaults to current begin label or else "LinearRelation"
1262 * @param pContext
1263 * Write context to provide contextual information
1264 *
1265 * @exception Exception
1266 * - IO errors (id 1)
1267 * - token mismatch (id 50)
1268 */
1269 virtual void DoRead(TokenReader& tr, const std::string& rLabel = "", const Type* pContext=0);
1270
1271
1272
1273
1274};
1275
1276
1277
1278
1279
1280} // name space
1281#endif
1282
#define FAUDES_API
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:918
virtual const std::string & Name(void) const
virtual void Name(const std::string &name)
Scalar::Type * mpData
virtual const std::string & Name(void) const
virtual void Name(const std::string &name)
Scalar::Type * mpData
uint32_t Idx
Parma_Polyhedra_Library::C_Polyhedron & UserData(const Polyhedron &fpoly)

libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen