input_test_val type_test(const octave_value& to_be_test, data_type reference_type ) { input_test_val A = input_test_val(); A.value = true; switch( reference_type ) { case real_scalar: A.value = !to_be_test.is_real_scalar(); if(A.value) A.error_code="Argument isn't real scalar"; break; case complex_scalar: A.value = !(to_be_test.is_complex_scalar() ); if(A.value) A.error_code="Argument isn't complex scalar"; break; case complex_array: A.value = !(to_be_test.is_complex_type() && (to_be_test.rows() > 1 || to_be_test.columns() > 1) ); if(A.value) A.error_code="Argument isn't complex array"; break; case real_array: A.value = !(to_be_test.is_real_type() && (to_be_test.rows() > 1 || to_be_test.columns() > 1) ); if(A.value) A.error_code="Argument isn't real array"; break; } return A; }
float64_t COctaveInterface::get_real() { const octave_value f=get_arg_increment(); if (!f.is_real_scalar()) SG_ERROR("Expected Scalar Float as argument %d\n", m_rhs_counter); return f.double_value(); }
bool COctaveInterface::get_bool() { const octave_value b=get_arg_increment(); if (b.is_bool_scalar()) return b.bool_value(); else if (b.is_real_scalar()) return (b.double_value()!=0); else SG_ERROR("Expected Scalar Boolean as argument %d\n", m_rhs_counter); return false; }
int32_t COctaveInterface::get_int() { const octave_value i=get_arg_increment(); if (!i.is_real_scalar()) SG_ERROR("Expected Scalar Integer as argument %d\n", m_rhs_counter); double s=i.double_value(); if (s-CMath::floor(s)!=0) SG_ERROR("Expected Integer as argument %d\n", m_rhs_counter); return int32_t(s); }