A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/Splines_8cpp_source.html below:

NCBI C++ ToolKit: src/gui/utils/splines/Splines.cpp Source File

37 #include <gui/utils/splines/Splines.hh> 43 #pragma GCC diagnostic ignored "-Wc++98-compat" 46 #pragma clang diagnostic ignored "-Wc++98-compat" 62

{

return

pow( x, 1.0/3.0 ); }

66  #if __cplusplus <= 199711L 71

{

return

pow( x, 1.0/3.0 ); }

94  for

( integer k = 1; k < npts-1; ++k )

95  t

[k] =

static_cast<

real_type

>

(k)/

static_cast<

real_type

>

(npts);

103

real_type

const

pnts[],

107

real_type

const

* p0 = pnts;

108  for

( integer k = 1; k < npts; ++k ) {

109

real_type

const

* p1 = p0 + ld_pnts;

111  for

( integer j = 0; j < dim; ++j ) {

112

real_type c = p1[j] - p0[j];

115  t

[k] =

t

[k-1] + sqrt(dst);

117  for

( integer k = 1; k < npts-1; ++k )

t

[k] /=

t

[npts-1];

126

real_type

const

pnts[],

128

real_type

const

alpha,

131

real_type

const

* p0 = pnts;

132  for

( integer k = 1; k < npts; ++k ) {

133

real_type

const

* p1 = p0 + ld_pnts;

135  for

( integer j = 0; j < dim; ++j ) {

136

real_type c = p1[j] - p0[j];

139  t

[k] =

t

[k-1] + pow(dst,alpha/2);

141  for

( integer k = 1; k < npts-1; ++k )

t

[k] /=

t

[npts-1];

150

real_type

const

pnts[],

159

real_type

const

pnts[],

168

real_type

const

pnts[],

194  for

(

size_t

j = 0;

spline_type

[j] !=

nullptr

; ++j ) {

197

std::ostringstream ost;

198

ost <<

"string_to_splineType("

<<

n

<<

") unknown type\n"

;

199  throw

std::runtime_error(ost.str());

203  static

real_type

const m_2pi

= 6.28318530717958647692528676656;

225

real_type imag[2] ) {

228

real_type

const

&

C

=

a

[0];

229

real_type

const

&

B

=

a

[1];

230

real_type

const

&

A

=

a

[2];

232

real[0] = real[1] = imag[0] = imag[1] = 0;

234

pair<int,int> res(0,0);

235  if

( isZero(

a

[0]) ) {

239

real_type twoA = 2*

A

;

240

real_type d =

B

*

B

- 4*

A

*

C

;

241

real_type absd =

abs

(d);

246

real_type

r

= sqrt(absd);

248

real[0] = real[1] = -

B

/twoA;

249

imag[0] =

abs

(

r

/twoA);

255

real[0] =

abs

(

r

/twoA);

259  if

( w > 0 ) w +=

r

;

else

w -=

r

;

284

real_type imag[3] ) {

287

real[0] = real[1] = real[2] =

288

imag[0] = imag[1] = imag[2] = 0;

291  if

( isZero(

a

[0]) ) {

301

real_type

const C

=

a

[0]/

a

[3];

302

real_type

const B

=

a

[1]/

a

[3];

303

real_type

const A

=

a

[2]/

a

[3];

306

real_type

const A3

=

A

/3;

307

real_type

const

p =

B

-

A

*

A3

;

308

real_type

const

q =

C

+

A3

*(2*(

A3

*

A3

)-

B

);

316  return

pair<int,int>(1,0);

319

real_type

const P

= (p/3)/

S

/

S

;

320

real_type

const

sqrtP = sqrt(

abs

(p/3))/

S

;

321

real_type

const

Q = (q/2)/

S

/

S

/

S

;

323

real_type

const

d =

P

*

P

*

P

+ Q*Q;

324

real_type

const

sqrtd = sqrt(

abs

(d));

326

pair<int,int> res(0,0);

331

real_type

tmp

= Q > 0 ? sqrtP : -sqrtP;

335

}

else if

( d > 0 ) {

340

w2 = - pow( sqrtd + Q, 1.0 / 3.0 );

343

w1 = pow( sqrtd - Q, 1.0 / 3.0 );

348

real[2] = -0.5*real[0];

349

imag[1] = (w1-w2)*sqrt(3.0/4.0);

356

real_type angle = atan2( sqrtd, -Q );

357  if

( angle < 0 ) angle +=

m_2pi

;

359

real_type re = sqrtP * cos(angle);

360

real_type im = sqrtP * sin(angle);

363

real[1] = real[2] = -re;

364

real[1] += sqrt(3.0) * im;

365

real[2] -= sqrt(3.0) * im;

369  for

( integer

i

= 0;

i

< res.first+res.second; ++

i

) {

389

real_type

const

Yp[],

393  for

(

size_t i

= 1;

i

< size_t(npts); ++

i

) {

394  if

( Y[

i

-1] > Y[

i

] )

return

-2;

395  if

( isZero(Y[

i

-1]-Y[

i

]) && X[

i

-1] < X[

i

] ) flag = 0;

398  for

(

size_t i

= 1;

i

< size_t(npts); ++

i

) {

399  if

( X[

i

] <= X[

i

-1] )

continue

;

400

real_type dd = (Y[

i

]-Y[

i

-1])/(X[

i

]-X[

i

-1]);

401

real_type m0 = Yp[

i

-1]/dd;

402

real_type m1 = Yp[

i

]/dd;

403  if

( m0 < 0 || m1 < 0 )

return

-1;

404  if

( m0 <= 3 && m1 <= 3 ) {

405  if

( flag > 0 &&

i

> 1 && (isZero(m0) || isZero(m0-3) ) ) flag = 0;

406  if

( flag > 0 &&

i

<

size_t

(npts-1) && (isZero(m1) || isZero(m1-3) ) ) flag = 0;

408

real_type

tmp1

= 2*m0+m1-3;

409

real_type tmp2 = 2*(m0+m1-2);

410

real_type tmp3 = m0*tmp2-(

tmp1

*

tmp1

);

412  if

( tmp3 < 0 )

return

-1;

414  if

( tmp3 > 0 )

return

-1;

416  if

( isZero(tmp3) ) flag = 0;

430  if

( npts <= 2 ) { lastInterval = 0;

return

; }

433

real_type

const

* XL = X+lastInterval;

435  if

( x >= X[npts-2] ) {

436

lastInterval = npts-2;

437

}

else if

( x < XL[2] ) {

440

real_type

const

* XE = X+npts;

441

lastInterval += integer(std::lower_bound( XL, XE, x )-XL);

442  if

( X[lastInterval] > x ) --lastInterval;

444

}

else if

( x < XL[0] ) {

447

}

else if

( XL[-1] <= x ) {

450

lastInterval = integer(std::lower_bound( X, XL, x )-X);

451  if

( X[lastInterval] > x ) --lastInterval;

461

Spline::build( real_type

const

x[], integer incx,

462

real_type

const

y[], integer incy,

465  for

( integer

i

= 0;

i

<

n

; ++

i

) X[

i

] = x[

i

*incx];

466  for

( integer

i

= 0;

i

<

n

; ++

i

) Y[

i

] = y[

i

*incy];

475

s <<

"Spline `"

<< _name

477

<<

" of order: "

<< order();

479

s <<

"\nxMin = "

<< xMin() <<

" xMax = "

<< xMax()

480

<<

"\nyMin = "

<< yMin() <<

" yMax = "

<< yMax();

487

Spline::pushBack( real_type x, real_type y ) {

489

SPLINE_ASSERT( x >= X[

size_t

(npts-1)],

490  "Spline::pushBack, non monotone insert at insert N. "

<< npts <<

491  "\nX[ "

<< npts-1 <<

"] = "

<< X[

size_t

(npts-1)] <<

492  "\nX[ "

<< npts <<

"] = "

<< x );

494  if

( npts_reserved == 0 ) {

496

}

else if

( npts >= npts_reserved ) {

498

integer saved_npts = npts;

499

vector<real_type> Xsaved, Ysaved;

500

Xsaved.resize(

size_t

(npts) );

501

Ysaved.resize(

size_t

(npts) );

505

reserve( (npts+1) * 2 );

507  std::copy

( Xsaved.begin(), Xsaved.end(), X );

508  std::copy

( Ysaved.begin(), Ysaved.end(), Y );

518

Spline::setOrigin( real_type x0 ) {

519

real_type Tx = x0 - X[0];

521  while

( ix < X+npts ) *ix++ += Tx;

527

Spline::setRange( real_type xmin, real_type xmax ) {

528

SPLINE_ASSERT( xmax > xmin,

529  "Spline::setRange( "

<< xmin <<

530  " , "

<< xmax <<

" ) bad range "

);

531

real_type

S

= (xmax - xmin) / ( X[npts-1] - X[0] );

532

real_type Tx = xmin -

S

* X[0];

533  for

( real_type *ix = X; ix < X+npts; ++ix ) *ix = *ix *

S

+ Tx;

541  char const

header[] )

const

{

542

s << header <<

'\n'

;

543

real_type dx = (xMax()-xMin())/nintervals;

544  for

( integer

i

= 0;

i

<= nintervals; ++

i

) {

545

real_type x = xMin() +

i

*dx;

546

s << x <<

'\t'

<< (*this)(x) <<

'\n'

;

559  #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER 561  using

GenericContainerNamespace::GC_VEC_REAL;

562  using

GenericContainerNamespace::vec_real_type;

573

SPLINE_ASSERT( gc.exists(

"x"

),

574  "Spline["

<< _name <<

"]::setup missing `x` field!"

);

575

SPLINE_ASSERT( gc.exists(

"y"

),

576  "Spline["

<< _name <<

"]::setup missing `y` field!"

);

578

GenericContainer

const

& gc_x = gc(

"x"

);

579

GenericContainer

const

& gc_y = gc(

"y"

);

583

std::ostringstream ost;

584

ost <<

"Spline["

<< _name <<

"]::setup, field `x'"

;

585

gc_x.copyto_vec_real ( x, ost.str().c_str() );

588

std::ostringstream ost;

589

ost <<

"Spline["

<< _name <<

"]::setup, field `y'"

;

590

gc_y.copyto_vec_real ( y, ost.str().c_str() );

void transform(Container &c, UnaryFunction *op)

void FangHung(integer dim, integer npts, real_type const pnts[], integer ld_pnts, real_type t[])

pair< int, int > quadraticRoots(real_type const a[3], real_type real[2], real_type imag[2])

quadratic polinomial roots

void centripetal(integer dim, integer npts, real_type const pnts[], integer ld_pnts, real_type const alpha, real_type t[])

static real_type const m_2pi

void uniform(integer, integer npts, real_type const [], integer, real_type t[])

static real_type cbrt(real_type x)

void universal(integer dim, integer npts, real_type const pnts[], integer ld_pnts, real_type t[])

static real_type const machineEps

char const * spline_type[]

void chordal(integer dim, integer npts, real_type const pnts[], integer ld_pnts, real_type t[])

void FoleyNielsen(integer dim, integer npts, real_type const pnts[], integer ld_pnts, real_type t[])

pair< int, int > cubicRoots(real_type const a[4], real_type real[3], real_type imag[3])

cubic polinomial roots

SplineType string_to_splineType(std::string const &nin)

void updateInterval(integer &lastInterval, real_type x, real_type const X[], integer npts)

integer checkCubicSplineMonotonicity(real_type const X[], real_type const Y[], real_type const Yp[], integer npts)

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)

static const char * type_name(CS_INT value)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4