/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #include "MGCLStdAfx.h" #include "mg/nlbit.h" #include "mg/PPRep.h" #include "mg/LBRepEndC.h" #include "mg/LBRep.h" #include "mg/LinearEquation.h" #include "mg/Tolerance.h" #if defined(_DEBUG) #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif using namespace std; // MGLBRep.cpp // // Implement MGLBRep class. //******Smoothing function fo Shoenberg and Reinch variation. //This smoothing function keeps boundary condition, start and end point //and 1st derivative at start and end point. //Q-transpose is the tridiagonal matrix of order n*n with general row //{1/dxim1 -(1/dxim1+1/dxi) 1/dxi} for i=0,...,n-1, //D is the diagonal matrix of dy[i] for i=0,...,n-1, //constructQTD will construct dx, QtDDQ, and QtY of below. void constructQTD( const MGNDDArray& tau, //Data point abscissa const MGBPointSeq& y, //Data point ordinates. const double* dy,// dy[i] is the weight at tau[i] for i=0,..., tau.length()-1. std::vector& dx,//dx[i]=tau[i+1]-tau[i]] for i=0,.., n-2, will be output MGBPointSeq& QtDDQ, //three bands of Q-transpose*D*D*Q at and above the diagonal //will be output. //QtDDQ(i,0)=(i,i), //QtDDQ(i,1)=(i,i+1) and (i+1,i) //QtDDQ(i,2)=(i,i+2) and (i+2,i) for i=0,...,n-1 MGBPointSeq& QtY) //Q-transpose*y will be output //QtY(.,0) and (.,n-1) will be modified to take the end conditions into account. { int n=tau.length();assert(n>=3); int nm1=n-1, nm2=n-2; int sd=y.sdim(); int i,j; dx.resize(nm1); dx[0]=tau[1]-tau[0]; MGBPointSeq QtD(n,3);//QtD(i,0) is (i,i-1), (i,1) is (i,i) , and (i,2) is (i,i+1). QtD(0,0)=0.; QtD(0,1)=-dy[0]/dx[0]; QtD(0,2)=dy[1]/dx[0]; for(i=1; i