Пример #1
0
  void evalTo(Dest& y) const
  {
    y.setZero(4);

    y(0) += 2 * m_rhs(0); y(1) += 1 * m_rhs(0);
    y(0) += 1 * m_rhs(1); y(1) += 2 * m_rhs(1); y(2) += 1 * m_rhs(1);
    y(1) += 1 * m_rhs(2); y(2) += 2 * m_rhs(2); y(3) += 1 * m_rhs(2);
    y(2) += 1 * m_rhs(3); y(3) += 2 * m_rhs(3);
  }
Пример #2
0
/// get type of current argument (does not increment argument counter)
IFType COctaveInterface::get_argument_type()
{
	octave_value arg=m_rhs(m_rhs_counter);

	if (arg.is_real_scalar())
		return SCALAR_REAL;
	if (arg.is_bool_scalar())
		return SCALAR_BOOL;

	if (arg.is_char_matrix())
		return STRING_CHAR;
	if (arg.is_uint8_type() && arg.is_matrix_type())
		return STRING_BYTE;

	if (arg.is_sparse_type())
	{
		if (arg.is_uint8_type())
			return SPARSE_BYTE;
		if (arg.is_char_matrix())
			return SPARSE_CHAR;
		if (arg.is_int32_type())
			return SPARSE_INT;
		if (arg.is_double_type())
			return SPARSE_REAL;
		if (arg.is_int16_type())
			return SPARSE_SHORT;
		if (arg.is_single_type())
			return SPARSE_SHORTREAL;
		if (arg.is_uint16_type())
			return SPARSE_WORD;

		return UNDEFINED;
	}

	if (arg.is_cell())
	{
		Cell c = arg.cell_value();

		if (c.nelem()>0)
		{
			if (c.elem(0).is_char_matrix() && c.elem(0).rows()==1)
				return STRING_CHAR;
			if (c.elem(0).is_uint8_type() && c.elem(0).rows()==1)
				return STRING_BYTE;
			if (c.elem(0).is_int32_type() && c.elem(0).rows()==1)
				return STRING_INT;
			if (c.elem(0).is_int16_type() && c.elem(0).rows()==1)
				return STRING_SHORT;
			if (c.elem(0).is_uint16_type() && c.elem(0).rows()==1)
				return STRING_WORD;
		}
	}


	if (arg.is_matrix_type() && arg.ndims()==1 && arg.rows()==1)
	{
		if (arg.is_uint32_type())
			return VECTOR_INT;
		if (arg.is_double_type())
			return VECTOR_REAL;
		if (arg.is_int16_type())
			return VECTOR_SHORT;
		if (arg.is_single_type())
			return VECTOR_SHORTREAL;
		if (arg.is_uint16_type())
			return VECTOR_WORD;

		return UNDEFINED;
	}

	if (arg.is_matrix_type() && arg.ndims()==2)
	{
		if (arg.is_uint32_type())
			return DENSE_INT;
		if (arg.is_double_type())
			return DENSE_REAL;
		if (arg.is_int16_type())
			return DENSE_SHORT;
		if (arg.is_single_type())
			return DENSE_SHORTREAL;
		if (arg.is_uint16_type())
			return DENSE_WORD;

		return UNDEFINED;
	}

	if (arg.is_matrix_type() && arg.ndims()>2)
	{
		if (arg.is_uint8_type())
			return NDARRAY_BYTE;
		if (arg.is_uint32_type())
			return NDARRAY_INT;
		if (arg.is_double_type())
			return NDARRAY_REAL;
		if (arg.is_int16_type())
			return NDARRAY_SHORT;
		if (arg.is_single_type())
			return NDARRAY_SHORTREAL;
		if (arg.is_uint16_type())
			return NDARRAY_WORD;

		return UNDEFINED;
	}

	if (arg.is_map())
		return ATTR_STRUCT;

	return UNDEFINED;
}