Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
6314f7cd
Commit
6314f7cd
authored
2 years ago
by
Emmanuel Labourasse
Browse files
Options
Downloads
Patches
Plain Diff
add derivation feature
parent
1d2c3138
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/analysis/PolynomialP.hpp
+90
-3
90 additions, 3 deletions
src/analysis/PolynomialP.hpp
with
90 additions
and
3 deletions
src/analysis/PolynomialP.hpp
+
90
−
3
View file @
6314f7cd
...
...
@@ -217,7 +217,6 @@ class PolynomialP
if
constexpr
(
Dimension
==
1
)
{
abs_pos
=
relative_pos
[
0
];
}
else
if
constexpr
(
Dimension
==
2
)
{
size_t
total_degree
=
relative_pos
[
0
]
+
relative_pos
[
1
];
abs_pos
=
total_degree
*
(
total_degree
+
1
)
/
2
+
relative_pos
[
1
];
}
else
{
throw
NotImplementedError
(
"Not yet Available in 3D"
);
...
...
@@ -316,9 +315,97 @@ class PolynomialP
}
return
Q
;
}
else
{
throw
UnexpectedError
(
"Not yet Available in 3D"
);
throw
NotImplementedError
(
"Not yet Available in 3D"
);
}
}
}
PUGS_INLINE
constexpr
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
PolynomialP
<
N
,
Dimension
>&
P
)
{
// os << "P(x) = ";
bool
all_coef_zero
=
true
;
if
(
N
==
0
)
{
os
<<
P
.
coefficients
()[
0
];
return
os
;
}
if
constexpr
(
Dimension
==
1
)
{
if
(
N
!=
1
)
{
if
(
P
.
coefficients
()[
N
]
!=
0.
)
{
if
(
P
.
coefficients
()[
N
]
<
0.
)
{
os
<<
"- "
;
}
if
(
P
.
coefficients
()[
N
]
!=
1
&&
P
.
coefficients
()[
N
]
!=
-
1
)
{
os
<<
std
::
abs
(
P
.
coefficients
()[
N
]);
}
os
<<
"x^"
<<
N
;
all_coef_zero
=
false
;
}
}
for
(
size_t
i
=
N
-
1
;
i
>
1
;
--
i
)
{
if
(
P
.
coefficients
()[
i
]
!=
0.
)
{
if
(
P
.
coefficients
()[
i
]
>
0.
)
{
os
<<
" + "
;
}
else
if
(
P
.
coefficients
()[
i
]
<
0.
)
{
os
<<
" - "
;
}
if
(
P
.
coefficients
()[
i
]
!=
1
&&
P
.
coefficients
()[
i
]
!=
-
1
)
{
os
<<
std
::
abs
(
P
.
coefficients
()[
i
]);
}
os
<<
"x^"
<<
i
;
all_coef_zero
=
false
;
}
}
if
(
P
.
coefficients
()[
1
]
!=
0.
)
{
if
(
P
.
coefficients
()[
1
]
>
0.
&&
N
!=
1
)
{
os
<<
" + "
;
}
else
if
(
P
.
coefficients
()[
1
]
<
0.
)
{
os
<<
" - "
;
}
if
(
P
.
coefficients
()[
1
]
!=
1
&&
P
.
coefficients
()[
1
]
!=
-
1
)
{
os
<<
std
::
abs
(
P
.
coefficients
()[
1
]);
}
os
<<
"x"
;
all_coef_zero
=
false
;
}
if
(
P
.
coefficients
()[
0
]
!=
0.
||
all_coef_zero
)
{
if
(
P
.
coefficients
()[
0
]
>
0.
)
{
os
<<
" + "
;
}
else
if
(
P
.
coefficients
()[
0
]
<
0.
)
{
os
<<
" - "
;
}
os
<<
std
::
abs
(
P
.
coefficients
()[
0
]);
}
return
os
;
}
else
if
constexpr
(
Dimension
==
2
)
{
for
(
size_t
j
=
N
;
j
>
0
;
--
j
)
{
for
(
size_t
i
=
N
-
j
;
i
>
0
;
--
i
)
{
double
coef
=
P
[
i
,
j
];
if
(
coef
!=
0.
)
{
if
(
coef
>
0.
)
{
os
<<
" + "
;
}
else
if
(
coef
<
0.
)
{
os
<<
" - "
;
}
if
(
coef
!=
1
&&
coef
!=
-
1
)
{
os
<<
std
::
abs
(
coef
);
}
if
(
i
==
0
)
{
os
<<
"y"
<<
j
;
}
else
if
(
j
==
0
)
{
os
<<
"x^"
<<
i
;
}
else
{
os
<<
"x^"
<<
i
<<
"y^"
<<
j
;
}
all_coef_zero
=
false
;
}
}
}
return
os
;
}
else
{
throw
NotImplementedError
(
"Not yet Available in 3D"
);
}
}
PUGS_INLINE
constexpr
PolynomialP
()
noexcept
=
default
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment