Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CoMISo
CoMISo
Commits
d3a3b0fa
Commit
d3a3b0fa
authored
Jul 31, 2020
by
Max Lyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow setting largest exponent from the outside
parent
20123f2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
Utils/ExactConstraintSatisfaction.cc
Utils/ExactConstraintSatisfaction.cc
+17
-8
Utils/ExactConstraintSatisfaction.hh
Utils/ExactConstraintSatisfaction.hh
+3
-1
No files found.
Utils/ExactConstraintSatisfaction.cc
View file @
d3a3b0fa
...
...
@@ -9,6 +9,8 @@
namespace
COMISO
{
ExactConstraintSatisfaction
::
ExactConstraintSatisfaction
()
:
largest_exponent_
(
std
::
numeric_limits
<
int
>::
min
())
{
}
...
...
@@ -110,16 +112,23 @@ void ExactConstraintSatisfaction::print_vector(Eigen::VectorXi b)
std
::
cout
<<
std
::
endl
;
}
int
ExactConstraintSatisfaction
::
largest_exponent
(
const
Eigen
::
VectorXd
&
x
)
void
ExactConstraintSatisfaction
::
largest_exponent
(
const
Eigen
::
VectorXd
&
x
)
{
// only compute largest component if it was not set from the outside
if
(
largest_exponent_
==
std
::
numeric_limits
<
int
>::
min
())
set_largest_exponent
(
std
::
max
(
compute_largest_exponent
(
x
)
+
2
,
-
65
));
}
int
expo
=
-
65
;
for
(
int
i
=
0
;
i
<
x
.
size
();
i
++
)
{
expo
=
std
::
max
(
expo
,
static_cast
<
int
>
(
std
::
ceil
(
std
::
log2
(
std
::
abs
(
x
.
coeffRef
(
i
))))
+
2
));
}
largest_exponent_
=
expo
;
delta_
=
std
::
pow
(
2
,
expo
);
void
ExactConstraintSatisfaction
::
set_largest_exponent
(
int
_exponent
)
{
largest_exponent_
=
_exponent
;
delta_
=
std
::
pow
(
2
,
largest_exponent_
);
}
int
ExactConstraintSatisfaction
::
compute_largest_exponent
(
const
Eigen
::
VectorXd
&
x
)
{
double
max_elem
=
std
::
max
(
x
.
maxCoeff
(),
-
x
.
minCoeff
());
auto
expo
=
static_cast
<
int
>
(
std
::
ceil
(
std
::
log2
(
max_elem
)));
return
expo
;
}
...
...
Utils/ExactConstraintSatisfaction.hh
View file @
d3a3b0fa
...
...
@@ -33,7 +33,9 @@ public:
void
swap_rows
(
SP_Matrix_R
&
mat
,
int
row1
,
int
row2
);
void
eliminate_row
(
SP_Matrix_R
&
mat
,
Eigen
::
VectorXi
&
b
,
int
row1
,
int
row2
,
int
pivot_column
);
int
largest_exponent
(
const
Eigen
::
VectorXd
&
x
);
void
largest_exponent
(
const
Eigen
::
VectorXd
&
x
);
void
set_largest_exponent
(
int
_exponent
);
static
int
compute_largest_exponent
(
const
Eigen
::
VectorXd
&
x
);
int
index_pivot
(
const
sparseVec
&
row
);
double
F_delta
(
double
x
);
double
get_delta
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment