示例#1
0
文件: DuoFun.cpp 项目: cjang/chai
void DuoFun::accept(stack< ArrayDim >& v) const
{
    _b.accept(v);
    _a.accept(v);

    const ArrayDim a = v.top();
    v.pop();
    const ArrayDim b = v.top();
    v.pop();

    const size_t maxW = a.width > b.width ? a.width : b.width;
    const size_t maxH = a.height > b.height ? a.height : b.height;
    const size_t maxSlots = (a.slots > b.slots ? a.slots : b.slots);

    v.push( ArrayDim(maxW, maxH, maxSlots) );
}
示例#2
0
文件: RngFun.cpp 项目: cjang/chai
void RngFun::accept(stack< ArrayDim >& v) const
{
    v.push( ArrayDim(_W, _H, _slots) );
}
int CDSR_VMEval_SE::Summarize( CParseDsrSymbolTable& smbtable )
{
	if( !ArrayDim() ) return 0;

	long i, j;
	used_xvar.Flush();
	is_koshi = is_linear = 1;
	is_algebraic = is_differential = 0;
	data_type = 0;
	for( i = 0; i < (long) ArrayDim(); i++ )
	{
		is_koshi  = is_koshi  && (*this)[ i ].is_koshi;
		is_linear = is_linear && (*this)[ i ].is_linear;
		is_algebraic = is_algebraic || (*this)[ i ].is_algebraic;
		is_differential = is_differential || (*this)[ i ].is_differential;
		data_type = (*this)[ i ].data_type;
		for( j = 0; j < (long) (*this)[ i ].used_xvar.ArrayDim(); j++ )
			if( used_xvar.Find( (*this)[ i ].used_xvar[ j ] ) == INT_MAX )
				used_xvar.Add( (*this)[ i ].used_xvar[ j ] );
		for( j = 0; j < (long) (*this)[ i ].used_dxvar.ArrayDim(); j++ )
			if( used_xvar.Find( (*this)[ i ].used_dxvar[ j ] ) == INT_MAX )
				used_xvar.Add( (*this)[ i ].used_dxvar[ j ] );
	}

	long _unknowns = getUnknownsNumber( smbtable );
#if _DEBUG
	if( used_xvar_idx.ArrayDim() != _unknowns )
		throw _T("CDSR_VMEval_SE::Summarize : internal problem");
#endif
	if( (is_differential && is_algebraic) || (!is_differential && !is_algebraic) )
	{
		smbtable.AddLine( _T("system of equations must be either differential or algebraical") );
		return -1;
	}
	else if( _unknowns != ArrayDim() )
	{
		smbtable.AddLine( QString("system of %1 equations has different number of equations and unknown variables").arg( is_differential ? _T("differential") : _T("algebraical") ) );
		return -1;
	}
	else if( is_differential && !is_koshi )
	{
		smbtable.AddLine( _T("system of differential equations must be in Koshi form") );
		return -1;
	}

	if( is_differential && is_koshi )
	{
		m_left_part.Flush();
		if( m_prime_index.ArrayDim() != ArrayDim() )
		{
			smbtable.AddLine( _T("internal problem while the system of ODE in Koshi form is forming") );
			return -1;
		}
		long i, j;
		for( i = 0; i < (long) ArrayDim(); i++ )
		{
			if( (*this)[ i ].used_dxvar.ArrayDim() != 1 )
			{
				smbtable.AddLine( _T("internal problem while the system of ODE in Koshi form is forming") );
				return -1;
			}
			CDSR_VMEval_SE_VPair pair( (*this)[ i ].used_dxvar[ 0 ], m_prime_index[ i ] );
			if( (j = m_left_part.Find( pair )) != INT_MAX )
			{
				smbtable.AddLine( QString("system of differential equations in Koshi form has duplicated left parts in equations %1 and %2").arg( j ).arg( i ) );
				return -1;
			}
			m_left_part.Add( pair );
		}
	}

	return 0;
}