Skip to content

Commit

Permalink
SeqServices.py for GlassBR implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
niazim3 committed Jul 24, 2018
1 parent 7865849 commit fd38569
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions CaseStudies/glass/src/Python/NewImplementation/SeqServices.py
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

6 comments on commit fd38569

@niazim3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smiths
Copy link
Owner

@smiths smiths commented on fd38569 Jul 24, 2018

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!

@niazim3
Copy link
Collaborator Author

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.

@smiths
Copy link
Owner

@smiths smiths commented on fd38569 Jul 27, 2018

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.

@niazim3
Copy link
Collaborator Author

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.

@smiths
Copy link
Owner

@smiths smiths commented on fd38569 Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Please sign in to comment.