Example #1
0
double Theis_unc( double x, double y, double time, struct Aquifer_Data ad, struct Well_Data *wd )
{
	double dx, dy, r, h2, sub1, sub2, sub3, sub4, s;
	int i, n, nR;

	h2 = ad.h * ad.h;
	s = 0;
	for( i = 0; i < (*wd).nW; i++ )
	{
		sub1 = 6.2831853 * (*wd).k[i];
		sub2 = (*wd).S[i] / ( 4.0 * (*wd).k[i] * (*wd).m[i] );
		dx = x - (*wd).x[i];	dy = y - (*wd).y[i];	r = dx * dx + dy * dy;
		sub3 = (*wd).r[i] * (*wd).r[i];
		if( r < sub3 ) r = sub3;
		sub3 = r * sub2;
		sub4 = time - (*wd).t[i][0];
		if( sub4 > 0 )
			s += ad.h - sqrt( h2 - (*wd).Q[i][0] * Ei( sub3 / sub4 ) / sub1 );
		nR = (*wd).nQ[i];
		for( n = 1; n < nR && (*wd).t[i][n] < time; n++ )
		{
			sub4 = time - (*wd).t[i][n];
			if( sub4 > 0 )
				s += ad.h - sqrt( h2 - ( (*wd).Q[i][n] - (*wd).Q[i][n - 1] ) * Ei( sub3 / sub4 ) / sub1 );
		}
	}
	return( s );
}
Example #2
0
double Theis( double x, double y, double time, struct Aquifer_Data ad, struct Well_Data *wd )
{
	double dx, dy, r, T, sub1, sub2, sub3, sub4, s;
	int i, n, nR;

	s = 0;
	for( i = 0; i < (*wd).nW; i++ )
	{
		T = (*wd).m[i] * (*wd).k[i]; /* transmissivity */
		sub1 = 12.5663706 * T; /* 4 * PI = 12.5663706 */
		sub2 = (*wd).S[i] / ( 4.0 * T );
		dx = x - (*wd).x[i];	dy = y - (*wd).y[i];	r = dx * dx + dy * dy; /* squared radial distance */
		sub3 = (*wd).r[i] * (*wd).r[i]; /* squared well radius */
		if( r < sub3 ) r = sub3;
		sub3 = r * sub2;
		sub4 = time - (*wd).t[i][0];
		if( sub4 > 0 )
			s += (*wd).Q[i][0] * Ei( sub3 / sub4 ) / sub1; /* initial drawdown */
		nR = (*wd).nQ[i]; /* number of step pumping rate changes */
		for( n = 1; n < nR && (*wd).t[i][n] < time; n++ ) /* loop through all the pumping rates */
		{
			sub4 = time - (*wd).t[i][n];
			if( sub4 > 0 )
				s += ( (*wd).Q[i][n] - (*wd).Q[i][n - 1] ) * Ei( sub3 / sub4 ) / sub1;
		}
	}
	return( s );
}
Example #3
0
void MarkovExpectation::compute(FitContext *fc, const char *what, const char *how)
{
	if (fc) {
		for (auto c1 : components) {
			c1->compute(fc, what, how);
		}
	}

	omxRecompute(initial, fc);
	if (initialV != omxGetMatrixVersion(initial)) {
		omxCopyMatrix(scaledInitial, initial);
		EigenVectorAdaptor Ei(scaledInitial);
		if (scale == SCALE_SOFTMAX) Ei.derived() = Ei.array().exp();
		if (scale != SCALE_NONE) {
			Ei /= Ei.sum();
		}
		if (verbose >= 2) mxPrintMat("initial", Ei);
		initialV = omxGetMatrixVersion(initial);
	}

	if (transition) {
		omxRecompute(transition, fc);
		if (transitionV != omxGetMatrixVersion(transition)) {
			omxCopyMatrix(scaledTransition, transition);
			EigenArrayAdaptor Et(scaledTransition);
			if (scale == SCALE_SOFTMAX) Et.derived() = Et.array().exp();
			if (scale != SCALE_NONE) {
				Eigen::ArrayXd v = Et.colwise().sum();
				Et.rowwise() /= v.transpose();
			}
			if (verbose >= 2) mxPrintMat("transition", Et);
			transitionV = omxGetMatrixVersion(transition);
		}
	}
}
void CEmpEdit::OnBnClickedButton6()
{
	// TODO: Update
	CString SqlString,s1;
	CString var_name,var_id,var_sh,var_sa,var_dep,var_Eid;
	int flg=0,col_index=1;
	
	CEmpTable recset(&database);
	
	EID->GetWindowText(var_id);
	ENA->GetWindowText(var_name);
	EWO->GetWindowText(var_sh);
	ESA->GetWindowText(var_sa);
	EDE->GetWindowText(var_dep);
	

	CString coma(", ");
	//CString CB(");");
	CString sc(" ;");
	CString Quo("'");
	CString Ei("  [Employee ID] = ");
	CString De(" , [Deprtment] = ");
	CString Sh(" , [Shift] = ");
	CString Sa(" , [Salary] = ");
	CString Id(" [ID] = ");
	CString sp(" AND ");
	CString wh(" WHERE "); 
	CString Bo(" ( ");
	CString Bc(" ) ");	
		recset.Open(CRecordset::dynaset,_T("SELECT * FROM EmpTable"),CRecordset::readOnly);

		recset.SetAbsolutePosition(rec_index);
		//recset.GetFieldValue(col_index,var_id);
		recset.GetFieldValue(col_index-1,var_Eid);

		
		s1.Format("UPDATE EmpTable SET [Employee Name] = ");

		
		SqlString=s1+Quo+var_name+Quo+De+Quo+var_dep+Quo+Sh+Quo+var_sh+Quo+Sa+var_sa+wh+Id+var_Eid+sc;
		AfxMessageBox(SqlString);
			try
{
   database.ExecuteSQL(SqlString);
}
catch(CDBException* pe)
{
	flg=1;
   // The error code is in pe->m_nRetCode
   pe->ReportError();
   pe->Delete();
}
if (flg == 0)
{
MessageBox(_T("Record Successfully Updated To The Database"),_T("Successfull")); 
}


	}
Example #5
0
void MarkovExpectation::populateAttr(SEXP robj)
{
	compute(0, 0, 0); // needed? TODO

	MxRList out;

	EigenVectorAdaptor Ei(scaledInitial);
	const char *initialName = isMixtureInterface? "weights" : "initial";
	out.add(initialName, Rcpp::wrap(Ei));

	if (scaledTransition) {
		EigenMatrixAdaptor Et(scaledTransition);
		out.add("transition", Rcpp::wrap(Et));
	}

	Rf_setAttrib(robj, Rf_install("output"), out.asR());
}
Example #6
0
// Plane is P(u, w) = A + u B + w C ;
// problem here, both line & plane's loop must intersect on the interior // wh 7/18/01, p321
HRESULT CPlaneStep::intersect( CLineStep *pLine,             // in,  line to be intersected.// Q(t) = D + t E;
                               intersectionType& eIntersect, // out, classification of the type of intersection, endpoint intersections are relative to l1
                               CrcPtrArray* pPointXs ,       // out, intersection points
                               double& paramU,               // out, intersection u parameter on plane
                               double& paramV,               // out, intersection v parameter on plane
                               double  paramT[2])            // out, intersection parameter on line
{
    CVectorStep axis ( *(m_pPosition->m_pAxis));
    bool bWithinTol = false;
    axis.withinTol( bWithinTol );
    ASSERT( !bWithinTol );
    CVectorStep *pAxis = &axis;
    CVectorStep loc  ( *(m_pPosition->m_pLocation));
    loc.withinTol( bWithinTol );
    ASSERT( !bWithinTol );
    CVectorStep *pLoc  = &loc;
    double bxc_a = dotProduct( *pAxis, *pLoc);
    CVectorStep D  ( *pLine->m_pPos);
    D.withinTol( bWithinTol );
    ASSERT( !bWithinTol );
    CVectorStep *pD  = &D;
    double bxc_d = dotProduct( *pAxis, *pD);
    paramT[0] = bxc_a - bxc_d;// 7.7
    CVectorStep E  ( *pLine->m_pDir);
    CVectorStep *pE  = &E;
    double bxc_e = dotProduct( *pAxis, *pE);
//ASSERT(fabs(paramT[0]) > restol );
    if (restol2 < fabs(bxc_e)) {
        paramT[0] /= bxc_e;//(7.7)

        CCartesian_pointStep* pIntersectionPoint = new
        CCartesian_pointStep ( NULL, *pLine->m_pPos);
        CVectorStep Ei(*pE);
        CVectorStep *pEi = &Ei;
        *pEi *= paramT[0];
        *pIntersectionPoint += *pEi;
        double endparam = 1.0;// endparam of line
        double len = pLine->m_pDir->getLength();
        ASSERT(len>restol);
        if (len<restol) {
            return E_FAIL;
        } // wh 11/04/01
        double tolRel = restol/len;
        if ( paramT[0] < -tolRel ) {
            eIntersect = noIntersection;
        }
        else if ( paramT[0] <  tolRel ) {
            eIntersect = startpointIntersection;
            pPointXs->Add( (void*) pLine->m_pPos);
        }
        else if ( paramT[0] <  endparam - tolRel ) {
            eIntersect = interiorIntersection;
            pPointXs->Add( (void*)pIntersectionPoint );
        }
        else if ( paramT[0] <  endparam + tolRel ) {
            eIntersect = endpointIntersection;
            pPointXs->Add( (void*) pLine->m_pPos1);
        }
        else {
            eIntersect = noIntersection;//hiIntersection;// wh 10/18/01
        }
        pIntersectionPoint->release();// wh 10/20/01
    }
    else {
        if (this->onSurface( *pLine->m_pPos)) {
            eIntersect = coincidentIntersection;
            //  still need to find out if within bounds
            pPointXs->Add( (void*) pLine->m_pPos);

            pPointXs->Add( (void*) pLine->m_pPos1);
        }
        else {
            eIntersect = noIntersection;
        }

    }
    return S_OK;
}
Example #7
0
int prepare(const size_t Ntracks, gsl_vector * v_alpha, gsl_vector * v_d, gsl_matrix * m_D) {
  size_t i;  
  
  gsl_matrix * ma_D[Ntracks];
  gsl_matrix * ma_E[Ntracks];
  gsl_vector * va_d[Ntracks];
  gsl_vector_view v_alpha_vertex_view = gsl_vector_subvector(v_alpha,0,6); 
  gsl_vector * v_vertex = &v_alpha_vertex_view.vector;
  for(i = 0; i < Ntracks; i++) {
    gsl_vector_view v_alpha_track_view = gsl_vector_subvector(v_alpha,3+i*6,6);     
    gsl_vector * v_track = &v_alpha_track_view.vector;
    ma_D[i] = gsl_matrix_calloc(2,6);
    ma_E[i] = gsl_matrix_calloc(2,3);
    va_d[i] = gsl_vector_calloc(2);
    Di(v_vertex,v_track,ma_D[i]);
    Ei(v_vertex,v_track,ma_E[i]);
    di(v_vertex,v_track,va_d[i]);
  }

  /* Build generalised D matrix */

  gsl_matrix * m_E = gsl_matrix_calloc(2*Ntracks,3);
  stack_matrix_array(ma_E,Ntracks,m_E);

  gsl_matrix * m_zero = gsl_matrix_calloc(2,6); /* Temporary matrix, used for padding */
    
  /* First build cols */
  gsl_matrix * ma_Dcols[Ntracks+1]; /* +1 First col is for E */
  ma_Dcols[0] = m_E;
  size_t j,k;
  gsl_matrix * ma_Dpieces[Ntracks];  

  /* Allocate the memory */
  for(i = 0; i < Ntracks; i++) {
    ma_Dcols[i+1] = gsl_matrix_calloc(2*Ntracks,6); /* +1 First col is for E */  
  }  

  for(i = 0; i < Ntracks; i++) {
    /* Compute blocs order  */    
    for(k = 0; k < Ntracks; k++) {    
      if(i == k) ma_Dpieces[k] = ma_D[k];
      else ma_Dpieces[k] = m_zero; 
    }
    /* Build a column */
    stack_matrix_array(ma_Dpieces,Ntracks,ma_Dcols[i+1]); /* +1 First col is for E */

  }

  /* Juxtapose the cols. */
  juxtapose_matrix_array(ma_Dcols,Ntracks+1,m_D); /* +1 First col is for E */


  /* Build generalised d matrix */
  stack_vector_array(va_d,Ntracks,v_d);

  /* Clean the mess */
  for(i = 0; i < Ntracks; i++) {
    gsl_matrix_free(ma_D[i]);
    gsl_matrix_free(ma_E[i]);
    gsl_vector_free(va_d[i]);  
    gsl_matrix_free(ma_Dcols[i+1]); /* +1 First col is for E (bloc pointed by [0] will be freed later) */
  }
  gsl_matrix_free(m_E);
  gsl_matrix_free(m_zero);
  return 0;
}