-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thomas algorithm implementation in Common Lisp #604
Thomas algorithm implementation in Common Lisp #604
Conversation
(setf | ||
(svref d i) | ||
(/ | ||
(- (svref d i) (* (svref a i) (svref d (1- i)))) |
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.
If you want to write a macro, (- (svref d i) (* (svref a i) (svref d (1- i))))
is probably the level of granularity that you want, with a separate macro for the 1+
version. Since you aren't shortening the code by using macros, make sure you use a descriptive macro name.
(defun thomas (a b c d) | ||
"Returns the solutions to a tri-diagonal matrix destructively" | ||
(setf (svref c 0) (/ (svref c 0) (svref b 0))) | ||
(setf (svref d 0) (/ (svref d 0) (svref b 0))) |
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.
Same comment about the macro here. Give them good docstrings.
Poke for rebase. I think the only thing I care about from the review is printing in floating point. |
I'm almost done, I found that (helper b a c i) is used twice so I might make that a separate variable in the loop. I also need an explanation for what the helper function actually does. I discovered that I didn't need macros and that functions could do the job. |
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.
Ah, this one is over a year old...and done.
While I probably could've done some funky recursion with this. I'm keeping it simple for this first submission. The
svref
and thesetf
syntax is wordy and annoying so I might make a specific function or even a macro for that. The function is destructive so I either have to find a copy command for a vector or re-write the entire function.It'd be great to first have a review though.