## Bug #1095

### trend1d -Nf

Status: | Closed | Start date: | 2017-05-13 | |
---|---|---|---|---|

Priority: | Normal | Due date: | ||

Assignee: | Paul | % Done: | 100% | |

Category: | - | |||

Target version: | Candidate for next bugfix release | |||

Affected version: | 5.x-svn | Platform: |

**Description**

the following command don't end (need to use ctr+c to stop it):

gmt math -T10/110/1 T 25 DIV 2 MUL PI MUL COS = | gmt trend1d -f0-1f -Nf1+o0+l25 -Fp

using with option -Vd (see attached file), say that it try to solve:

y(x) = a + b * cos (1*x) + c * sin (1*x)

but after that it says that is trying to solve a polynomial:

20:trend1d: The partial polynomial will be represented via powers of x

35:trend1d: Convert from normalized polynomial to user-domain polynomial coefficients

A small modification make it finish and return what I expected:

gmt math -T10/110/1 T 25 DIV 2 MUL PI MUL COS = | gmt trend1d -f0-1f -NF1+o0+l25 -Fp 1 -2.94902990916e-16

I could check that in this case it try to solve:

y(x) = a * cos (1*x) + b * sin (1*x)

I was trying to work with -Nf option, but I'm geting strange results.

using 5.5.1_r18212

### History

#### #1 Updated by Joaquim almost 4 years ago

**Status**changed from*New*to*In Progress*

Hangs because in unscale_polynomial () L#450, and given that n=1, it falls into an infinite loop

for (j = 0; j <= n - 2; j++) { for (k = n - 1; k > j; k--) c[k-1] -= cnst * c[k]; }

#### #2 Updated by Paul almost 4 years ago

**Status**changed from*In Progress*to*Resolved***Assignee**set to*Paul***Target version**set to*Candidate for next bugfix release***% Done**changed from*0*to*100*

Fixed in r18272. Did not consider unsigned int n-2 going huge for n < 2.