-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SeqServices.py for GlassBR implemented
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
CaseStudies/glass/src/Python/NewImplementation/SeqServices.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## @file SeqServices.py | ||
# @brief Library module that provides services for processing sequences. | ||
# @date 07/24/2018 | ||
|
||
## @brief Checks to see if a given list is monotonically increasing | ||
# @param X list in question | ||
def isAscending ( X ): | ||
for i in range (0, len(X) - 1): | ||
if (X[i+1] <= X[i]): | ||
return False | ||
return True | ||
|
||
## @brief Checks to see if a given value is within the bounds of a provided list | ||
# @details Assumes isAscending is True | ||
# @param X list providing boundaries | ||
# @param x variable in question | ||
def isInBounds ( X , x ): | ||
if (X[0] <= x <= X[len(X) - 1]): | ||
return True | ||
return False | ||
|
||
## @brief Linear interpolation function | ||
# @details Assumes isAscending is True | ||
# @return interpolated value calculated using provided inputs | ||
def interpLin ( x1 , y1 , x2 , y2 , x ): | ||
return (((y2 - y1)/(x2 - x1))*(x - x1) + y1) # y value | ||
|
||
## @brief Quadratic interpolation function | ||
# @details Assumes isAscending is True | ||
# @return interpolated value calculated using provided inputs | ||
def interpQuad ( x0 , y0 , x1 , y1 , x2 , y2 , x ): | ||
return ( y1 + | ||
((y2 - y0)/(x2 - x0))*(x - x1) + | ||
((y2 - 2*y1 + y0)/(2*(pow(x2 - x1, 2))))*(pow(x - x1, 2))) | ||
|
||
## @brief Determines the best "placement" for a value against a provided list | ||
# @details Assumes isAscending is True and isInBounds is True | ||
# @param x the real number input which is getting compared to elements in the current sequence | ||
# @return The index at which X(i) <= v < X(i+1) holds true | ||
def index ( X , x ): | ||
for i in range(0, len(X) - 1): | ||
if ((X[i] <= x < X[i+1])): | ||
return i |
fd38569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#134
fd38569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see the doxygen comments. A makefile rule to make the documentation would also be great!
fd38569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation can now be run using
make doc
as of commit 95e6694 from the Python subdirectory.fd38569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see
make doc
added. However, it doesn't quite work with the Makefile rule. After creating the documentation, you move some of the files to the doc folder. For the html files are missing in the doc folder, so the html view is incomplete. For the latex file, I believe the pdf is correct, but the tex file likely won't compile because image files are missing. I think it would be fine to have html and latex folders, without the need for a doc folder. Then you wouldn't have to worry about the makefile rule to move files.fd38569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes can be seen in 7b0a37d.
fd38569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.