Talk:Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions

m
 
(6 intermediate revisions by 2 users not shown)
Line 28:
Also note that the code here (for example in the C++ implementation) is incomplete, as is the task description. To solve this, you need to know which rosettacode tasks contain the missing task description and how to adapt the code there to work here. (That may be simple - I do not know yet.)
 
Specifically, the task lacks a specific terminating condition. And the C++ implementation uses a .moreTerms() method which is not included in the implementation here. --Meanwhile [[User:Rdm|RdmContinued_fraction/Arithmetic/G(matrix_NG,_Contined_Fraction_N)]] has an "I am done when" clause in the task description and code which won't compile without the NG_8 implementation here (unless you remove that reference) and an implementation of the .moreTerms() method. Also the c++ implementation there (and here) has a further [[Usercurrently talk:Rdm|talkundocumented]]) 11:44,dependency 11on Julycode 2015in the task [[Continued_fraction_r2cf(UTCRational_N)]].
 
This is a somewhat depressing state of affairs - implementations should not be this incomplete -- users should not have to puzzle out which other rosetta code tasks they need to extract code from to debug an implementation. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 11:44, 11 July 2015 (UTC)
 
: Have added some links to the C++ entry, since no-one else was ever going to. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:37, 17 August 2020 (UTC)
 
:The main thing is that G, NG, matrixNG, N1, N2, NG4, and NG8 are quite ridiculous names, it would actually be better or at least less misleading if they were changed to Galloway, NigelGalloway, matrixNigelGalloway, Nigel1, Nigel2, NigelGalloway4 and NigelGalloway8. (Ha-Bloody-Ha). And Yes, that would also include moving things to two new pages names of<br>
:Continued_fraction/Arithmetic/Galloway(matrix_NigelGalloway,_Contined_Fraction_Nigel), and<br>
:Continued_fraction/Arithmetic/Galloway(matrix_NigelGalloway,_Contined_Fraction_Nigel1,_Contined_Fraction_Nigel2)
 
:Hopefully my latest Phix entry will help clarify/suggest better names for things.
 
:As noted, the scatterbox over several (inadequately linked) pages issue also needs addressing. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 14:18, 18 August 2020 (UTC)
 
==Rename/rewrite Suggestion==
The above two tasks should be renamed as simply "Continued_fraction/Arithmetic/Unary" and "Continued_fraction/Arithmetic/Binary", and
read more like this (for "Binary"):
 
Perform arbitrary mathethatical operations on two continued fractions, such as +, -, *, and /.
 
The suggested approach is to write a function/class/method apply_full_matrix(ctrl,cf1,cf2) which takes a 2x4 control array and two continued fractions, and yields a continued fraction result. Assume ctrl is eight plain integers of the form
{{ a12, a1, a2, a },
{ b12, b1, b2, b }}
 
Then the result of apply_full_matrix(ctrl,cf1,cf2) would be
 
(a12*cf1*cf2 + a1*cf1 + a2*cf2 + a)
-----------------------------------
(b12*cf1*cf2 + b1*cf1 + b2*cf2 + b)
 
For instance:
{{ 0, 1, 1, 0}, calculates cf1 + cf2
{ 0, 0, 0, 1}} (divided by 1)
 
{{ 0, 1,-1, 0}, calculates cf1 - cf2
{ 0, 0, 0, 1}} (divided by 1)
 
{{ 1, 0, 0, 0}, calculates cf1 * cf2
{ 0, 0, 0, 1}} (divided by 1)
 
{{ 0, 1, 0, 0}, calculates cf1
{ 0, 0, 1, 0}} divided by cf2
 
If a12,a1,b12,b1 are all 0 then cf1 is not required/referenced and apply_fm() could accept some form of dummy/null value for it.<br>
If a12,a2,b12,b2 are all 0 then cf2 is not required/referenced and apply_fm() could accept some form of dummy/null value for it.<br>
Such cases are covered by a "baby" 2x2 control matrix in <nowiki>[["Continued_fraction/Arithmetic/Unary"]]</nowiki>
(currently named/located as [[Continued_fraction/Arithmetic/G(matrix_NG,_Contined_Fraction_N)]])
and it should (in theory) be perfectly possible to use this full form to replicate those results.
 
If b12,b1,b2,b are all zero we are done (presumably if that was initial state we end up with no terms, corresponding to undefined/error/divide by zero).<br>
If a12,a1,a2,a are initially all zero the result should be zero.<br>
If a12,a1,a2,b12,b1,b2 are all zero then neither cf1 nor cf2 are required and the result is the constant fraction a/b (but in
continued fraction format). In effect we define apply_fm() as operations on ctrl which (eventually) make a12..b2 zero so that we
can then simply read the (rest of the) result from a and b.
 
At that point I ran out of steam... Maybe this can be finished(/tweaked here) in small steps? --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 14:18, 18 August 2020 (UTC)
10,327

edits