/** Get value of the DOM element. Returns value for elements recognized by get_ctl_type() function. 
 * \param[in] el \b const dom::element&, The element.
 * \return \b value_t, value of the element.
 **/
  inline value_t get_value(dom::element& el )
  {
    switch(get_ctl_type(el))
    {
      case CTL_EDIT:
      case CTL_DECIMAL:
      case CTL_CURRENCY:
      case CTL_PASSWORD:
      case CTL_NUMERIC: 
      case CTL_PROGRESS:        
      case CTL_SLIDER:          
      case CTL_SELECT_SINGLE:   
      case CTL_SELECT_MULTIPLE: 
      case CTL_DD_SELECT:       
      case CTL_TEXTAREA:
      case CTL_DATE:
      case CTL_CALENDAR:
      default:
        return el.get_value();

      // special cases:
      case CTL_UNKNOWN:         
        if( !aux::wcseq(el.get_attribute("type"),L"hidden"))
          break;
        //else fall below if it is hidden
      case CTL_BUTTON:          return value_t(el.get_attribute("value"));
      case CTL_CHECKBOX:        return get_checkbox_bits(el);
      case CTL_RADIO:           return get_radio_index(el);
      case CTL_HTMLAREA:        return value_t(el.get_html(false/*inner*/));
    }
    return value_t();
  }
 // returns bit mask - checkboxes set
 inline value_t get_checkbox_bits(dom::element& el )
 {
   selected_cb selected;
   dom::element r = el.parent(); // ATTN: I assume here that all checkboxes in the group belong to the same parent!
   r.find_all(&selected, "[type='checkbox'][name='%S']", el.get_attribute("name"));
   int m = 1, v = 0;
   for( unsigned int n = 0; n < selected.elements.size(); ++n, m <<= 1 )
     if ( selected.elements[n].get_state(STATE_CHECKED) ) v |= m;
   return selected.elements.size()==1?value_t(v==1):value_t(v); // for alone checkbox we return true/false 
 }
 inline value_t get_radio_index( dom::element& el )
 {
   selected_cb selected;
   dom::element r = el.parent(); // ATTN: I assume here that all radios in the group belong to the same parent!
   r.find_all(&selected, "[type='radio'][name='%S']", el.get_attribute("name"));
   for( unsigned int n = 0; n < selected.elements.size(); ++n )
     if ( selected.elements[n].get_state(STATE_CHECKED) )
       return value_t(int(n)); 
   return value_t();
 }
示例#4
0
    BOOST_FORCEINLINE
      static void matrix_compute(const size_t & n, const size_t & k, A1 & a1)
    {
      typedef typename boost::proto::result_of::child_c<A1&,0>::type       a_t;
      a_t & a = boost::proto::child_c<0>(a1);
      BOOST_AUTO_TPL(c, nt2::cumprod(nt2::_(value_t(2), value_t(n+1))));
      BOOST_AUTO_TPL(d, nt2::cumprod(nt2::_(value_t(n+1), value_t(2*n)))*c(n-1));

      a = nt2::hankel(c, d);
      if (k) a = nt2::rec(a);
    }
示例#5
0
void com_obj_test()
{
  com_object_t c;

  c.create("AutoItX.Control");

  c["argc"] = 2;
  c["callsig"] = "ii";
  c.insert_attribute("0", value_t("20"));
  c.insert_attribute("1", value_t("20"));

  c.invoke("MouseMove");
    //ct.invoke_fmt("MouseMove", "ii", "0", "0", 0);
}
示例#6
0
void setup_random(SCtx& ctx)
{
    srand(0);
    ctx.sum = 0;
    ctx.keys.clear();
    ctx.keys.resize(ctx.num_elements);
    ctx.randomkeys.clear();
    ctx.randomkeys.resize(ctx.num_elements);
    ctx.exists.clear();
    ctx.exists.resize(ctx.num_elements);

    for( size_t i = 0; i < ctx.num_elements; ++i )
    {
        keey_t key = rand();
        while( Exists(ctx.ht, key ) )
        {
            key = rand();
        }
        Put(ctx.ht, key, value_t(i+1) );
        ctx.keys[i] = key;
        ctx.randomkeys[i] = key;
        ctx.exists[i] = true;
        ctx.sum += key * (i+1);
    }
}
示例#7
0
void create_insert(SCtx& ctx)
{
	Init(ctx.ht, ctx.num_elements);

	for( size_t i = 0; i < ctx.num_elements; ++i )
		Put(ctx.ht, keey_t( i ), value_t( i ) );
}
示例#8
0
uint64_t insert_sequential(SCtx& ctx)
{
	for( size_t i = 0; i < ctx.num_elements; ++i )
		Put(ctx.ht, keey_t( i ), value_t( i ) );

	ASSERT( Size(ctx.ht) == ctx.num_elements );
	return 0;
}
示例#9
0
static inline value_t
get_value(const void *address)
{
	if (sizeof(align_t) > sizeof(value_t))
		return value_t(*(align_t*)address);
	else
		return *(value_t*)address;
}
示例#10
0
 value_t convert2(const container_t& c) {
     try {
         return c.operator value_t();
     }
     catch(const std::exception& e) {
         OH_FAIL("Unable to convert type '" << c.type().name()
             << "' to type '" << typeid(value_t).name() << "' - " << e.what());
     }
 }
示例#11
0
uint64_t insert_random(SCtx& ctx)
{
	srand(0);
	for( size_t i = 0; i < ctx.num_elements; ++i )
		Put(ctx.ht, ctx.randomkeys[i], value_t( i ) );

	ASSERT( Size(ctx.ht) == ctx.num_elements );
	return 0;
}
示例#12
0
 BOOST_FORCEINLINE
   static void det_compute(const size_t & n, const size_t & k, A1 & a1)
 {
   value_t d = One<value_t>();
   if (!k)
   {
     for(size_t i=1;  i <= n-1; ++i)
       d *= nt2::prod(nt2::_(value_t(1), value_t(i+1)))*nt2::prod(_(value_t(1), value_t(n-i)));
     d *= nt2::prod(nt2::_(value_t(1), value_t(n+1)));
   }
   else
   {
     for(size_t i=0;  i <= n-1; ++i)
       d = d*nt2::prod(nt2::_(value_t(1), value_t(i)))/nt2::prod(nt2::_(value_t(1), value_t(n+1+i)));
     if (nt2::is_odd(n*(n-1)/2)) d = -d;
   }
   boost::proto::child_c<1>(a1) = d;
 }
示例#13
0
void obj_test()
{
	object_t obj1;
	object_t obj2;
	value_t *v1;
	std::string s;

	v1 = obj1.insert_attribute("v1", value_t(123));

	obj2 = obj1;

	obj2.to_string(s);
	printf("%s\n", s.c_str());
}
示例#14
0
scope_ptr
zookeeper_t::lock(writable_ptr::lock result, const path_t& folder) {
    path_t path = folder + "/lock";
    auto lock_state = std::make_shared<lock_state_t>(context_t({*log, zk}));
    auto& handler = lock_state->handler_scope.get_handler<lock_action_t>(
        context_t({*log, zk}),
        lock_state,
        path,
        std::move(folder),
        value_t(time(nullptr)),
        result
    );
    zk.create(path, handler.encoded_value, handler.ephemeral, handler.sequence, handler);
    return lock_state;
}
示例#15
0
static value_t custom_tagged_ordering_compare(value_t a, value_t b) {
  CHECK_DOMAIN(vdCustomTagged, a);
  CHECK_DOMAIN(vdCustomTagged, b);
  custom_tagged_phylum_t a_phylum = get_custom_tagged_phylum(a);
  custom_tagged_phylum_t b_phylum = get_custom_tagged_phylum(b);
  if (a_phylum != b_phylum)
    return compare_signed_integers(a_phylum, b_phylum);
  phylum_behavior_t *behavior = get_custom_tagged_phylum_behavior(a_phylum);
  value_t (*ordering_compare)(value_t a, value_t b) = behavior->ordering_compare;
  if (ordering_compare == NULL) {
    return unordered();
  } else {
    return ordering_compare(a, b);
  }
}
示例#16
0
    void Integer<T>::SetValue(value_t val)
    {
        const T theValue = T(val);
        if (value_t(theValue) < val)
        {
            std::stringstream s;
            s << __PRETTY_FUNCTION__ << " " << Name();
            s << " : value(" << val << ") bigger than the maximum allowed value(" << MaxValue() << ")";
            throw std::invalid_argument(s.str());
        }

        const T newVal =  SwapBytes<T>(theValue);
        const unsigned char* buf = reinterpret_cast<const unsigned char*>(&newVal);
        memcpy(&data_[0], buf, sizeof(newVal));
    }
示例#17
0
uint64_t adds_and_removes(SCtx& ctx)
{
	uint32_t percent = 30;
	uint32_t percent_lower = 50;
	uint32_t num_to_keep = (ctx.num_elements * percent_lower) / 100;
	uint32_t num_to_addremove = (ctx.num_elements * percent) / 100;
	if( num_to_addremove == 0 )
		num_to_addremove = 1;
	if( num_to_keep + num_to_addremove > ctx.num_elements )
		num_to_keep = ctx.num_elements - num_to_addremove;
	for(uint32_t i = 0; i < 100; ++i )
	{
		if( i & 1 )
		{
			// add
			uint32_t num_to_add = rand() % num_to_addremove;
			if( Size(ctx.ht) + num_to_add > ctx.num_elements )
				num_to_add = ctx.num_elements - Size(ctx.ht);

			for( size_t i = 0; i < num_to_add; ++i )
			{
				keey_t index = rand() % ctx.num_elements;
				Put(ctx.ht, ctx.randomkeys[ index ], value_t(i) );
				ctx.exists[index] = true;
			}
		}
		else
		{
			// remove
			uint32_t num_to_remove = rand() % num_to_addremove;
			if( Size(ctx.ht) - num_to_remove < num_to_keep )
				num_to_remove = Size(ctx.ht) - num_to_keep;

			for( size_t i = 0; i < num_to_remove; ++i )
			{
				keey_t index = rand() % ctx.num_elements;
				if( ctx.exists[index] )
				{
					Erase(ctx.ht, ctx.randomkeys[ index ] );
					ctx.exists[index] = false;
				}
			}
		}
	}
	return 0;
}
示例#18
0
static value_t object_ordering_compare(value_t a, value_t b) {
  CHECK_DOMAIN(vdHeapObject, a);
  CHECK_DOMAIN(vdHeapObject, b);
  heap_object_family_t a_family = get_heap_object_family(a);
  heap_object_family_t b_family = get_heap_object_family(b);
  if (a_family != b_family)
    // This may cause us to return a valid result even when a and b are not
    // comparable.
    return compare_signed_integers(a_family, b_family);
  family_behavior_t *behavior = get_heap_object_family_behavior(a);
  value_t (*ordering_compare)(value_t a, value_t b) = behavior->ordering_compare;
  if (ordering_compare == NULL) {
    return unordered();
  } else {
    return ordering_compare(a, b);
  }
}
示例#19
0
uint64_t create_insert_and_sum(SCtx& ctx)
{
	hashtable_t ht;
	Init(ht, ctx.num_elements);
	for( size_t i = 0; i < ctx.num_elements; ++i )
		Put(ht, keey_t( i ), value_t( i ) );

	uint64_t sum = 0;
#if defined(IMPL_DM_HASHTABLE)
	ht.Iterate(sum_callback, &sum);
#else
	auto it = IteratorBegin(ht);
	auto itend = IteratorEnd(ht);
	for( ; it != itend; IteratorNext(ht, it) )
		sum += IteratorGetValue(ht, it);
#endif
	return sum;
}
示例#20
0
void
subscribe_action_t::data_event(int rc, std::string value, const zookeeper::node_stat& stat) {
    if(rc == ZNONODE) {
        if(last_version != min_version && last_version != not_existing_version) {
            auto code = cocaine::error::make_error_code(static_cast<cocaine::error::zookeeper_errors>(rc));
            result->abort(code);
        } else {
            // Write that node is not exist to client only first time.
            // After that set a watch to see when it will appear
            if(last_version == min_version) {
                std::lock_guard<std::mutex> guard(write_lock);
                if (not_existing_version > last_version) {
                    result->write(versioned_value_t(value_t(), not_existing_version));
                }
            }
            try {
                ctx.zk.exists(path, *this, *this);
            } catch(const std::system_error& e) {
                COCAINE_LOG_WARNING(ctx.log, "failure during subscription(get): {}", e.what());
                result->abort(e.code());
            }
        }
    } else if (rc != 0) {
        auto code = cocaine::error::make_error_code(static_cast<cocaine::error::zookeeper_errors>(rc));
        result->abort(code);
    } else if (stat.numChildren != 0) {
        result->abort(cocaine::error::child_not_allowed);
    } else {
        version_t new_version(stat.version);
        std::lock_guard<std::mutex> guard(write_lock);
        if (new_version > last_version) {
            last_version = new_version;
            value_t val;
            try {
                result->write(versioned_value_t(unserialize(value), new_version));
            } catch(const std::system_error& e) {
                result->abort(e.code());
            }
        }
    }
}
示例#21
0
void create_sequential_table(SCtx& ctx)
{
	Init( ctx.ht, ctx.num_elements );

	ctx.sum = 0;
	ctx.keys.clear();
	ctx.keys.resize(ctx.num_elements);
	ctx.randomkeys.clear();
	ctx.randomkeys.resize(ctx.num_elements);
	ctx.exists.clear();
	ctx.exists.resize(ctx.num_elements);

	for( size_t i = 0; i < ctx.num_elements; ++i )
	{
		keey_t key = i;
		Put(ctx.ht, key, value_t( i+1 ) );
		ctx.keys[i] = key;
		ctx.randomkeys[i] = key;
		ctx.exists[i] = true;
		ctx.sum += key * (i+1);
	}

	ASSERT( Size(ctx.ht) == ctx.num_elements );
}
示例#22
0
void spawner_new_c::json_report(runner *runner_instance,
    rapidjson::PrettyWriter<rapidjson::StringBuffer, rapidjson::UTF16<> > &writer) {
    writer.StartObject();

    //for {
    report_class runner_report = runner_instance->get_report();
    options_class runner_options = runner_instance->get_options();
    //temporary
#define rapidjson_write(x) (writer.String(a2w(x)))
    rapidjson_write("Application");
    rapidjson_write(runner_report.application_name.c_str());
    rapidjson_write("Arguments");
    writer.StartArray();
    for (size_t i = 0; i < runner_options.get_arguments_count(); ++i) {
        rapidjson_write(runner_options.get_argument(i).c_str());
    }
    writer.EndArray();

    rapidjson_write("Limit");
    writer.StartObject();

    restrictions_class runner_restrictions = ((secure_runner*)runner_instance)->get_restrictions();
    struct {
        const char *field;
        unit_t unit;
        degrees_enum degree;
        restriction_kind_t restriction;
    } restriction_items[] = {
        { "Time", unit_time_second, degree_micro, restriction_processor_time_limit },
        { "WallClockTime", unit_time_second, degree_micro, restriction_user_time_limit },
        { "Memory", unit_memory_byte, degree_default, restriction_memory_limit },
        { "SecurityLevel", unit_no_unit, degree_default, restriction_security_limit },
        { "IOBytes", unit_memory_byte, degree_default, restriction_write_limit },
        { "IdlenessTime", unit_time_second, degree_micro, restriction_idle_time_limit },
        { "IdlenessProcessorLoad", unit_no_unit, degree_centi, restriction_load_ratio },
        { nullptr, unit_no_unit, degree_default, restriction_max },
    };
    for (int i = 0; restriction_items[i].field; ++i) {
        if (!runner_restrictions.check_restriction(restriction_items[i].restriction)) {
            continue;
        }
        rapidjson_write(restriction_items[i].field);
        if (restriction_items[i].degree == degree_default) {
            writer.Uint64(runner_restrictions[restriction_items[i].restriction]);
        }
        else {
            writer.Double((double)convert(
                value_t(restriction_items[i].unit, restriction_items[i].degree),
                value_t(restriction_items[i].unit),
                (long double)runner_restrictions[restriction_items[i].restriction]
            ));
        }
    }
    writer.EndObject();

    rapidjson_write("Options");
    writer.StartObject();
    rapidjson_write("SearchInPath");
    writer.Bool(runner_options.use_cmd);
    writer.EndObject();

    rapidjson_write("Result");
    writer.StartObject();
    struct {
        const char *field;
        uint64_t value;
        unit_t unit;
        degrees_enum degree;
    } result_items[] = {
        { "Time", runner_report.processor_time, unit_time_second, degree_micro },
        { "WallClockTime", runner_report.user_time, unit_time_second, degree_micro },
        { "Memory", runner_report.peak_memory_used, unit_memory_byte, degree_default },
        { "BytesWritten", runner_report.write_transfer_count, unit_memory_byte, degree_default },
        { "KernelTime", runner_report.kernel_time, unit_time_second, degree_micro },
        { "ProcessorLoad", (uint64_t)(runner_report.load_ratio * 100), unit_no_unit, degree_micro },
        { nullptr, 0, unit_no_unit, degree_default },
    };
    for (int i = 0; result_items[i].field; ++i) {
        rapidjson_write(result_items[i].field);
        if (result_items[i].degree == degree_default) {
            writer.Uint64(result_items[i].value);
        }
        else {
            writer.Double((double)convert(
                value_t(result_items[i].unit, result_items[i].degree),
                value_t(result_items[i].unit),
                (long double)result_items[i].value
            ));
        }
    }
    rapidjson_write("WorkingDirectory");
    rapidjson_write(runner_report.working_directory.c_str());
    writer.EndObject();

    rapidjson_write("StdOut");
    writer.StartArray();
    for (const auto& i : runner_options.stdoutput) {
        rapidjson_write(i.original.c_str());
    }
    writer.EndArray();
    rapidjson_write("StdErr");
    writer.StartArray();
    for (const auto& i : runner_options.stderror) {
        rapidjson_write(i.original.c_str());
    }
    writer.EndArray();
    rapidjson_write("StdIn");
    writer.StartArray();
    for (const auto& i : runner_options.stdinput) {
        rapidjson_write(i.original.c_str());
    }
    writer.EndArray();

    rapidjson_write("CreateProcessMethod");
    rapidjson_write(options.login.empty() ? "CreateProcess" : "WithLogon");
    rapidjson_write("UserName");
    writer.String(runner_report.login.c_str());
    rapidjson_write("TerminateReason");
    rapidjson_write(get_terminate_reason(runner_report.terminate_reason).c_str());
    rapidjson_write("ExitCode");
    writer.Uint(runner_report.exit_code);
    rapidjson_write("ExitStatus");
    rapidjson_write(ExtractExitStatus(runner_report).c_str());
    rapidjson_write("SpawnerError");
    writer.StartArray();
    std::vector<std::string> errors;
    errors.push_back(get_error_text());
    for (const auto& error : errors) {
        rapidjson_write(error.c_str());
    }
    writer.EndArray();
    writer.EndObject();
}
示例#23
0
void MsdFile::AddValue() /* (no extra charge) */
{
	values.push_back(value_t());
	values.back().params.reserve( 32 );
}
 constexpr int mult_ops() const {
     return value_t().mult_ops();
 }
 //solution exercice 1
 constexpr int sum_ops() const {
     return value_t().sum_ops();
 }
 constexpr auto operator() (T t_) const{
     return value_t()(t_);
 }
示例#27
0
文件: value.cpp 项目: JaapSuter/Lean
bool operator == (const value_t& v, const cons_ptr_t& ptr) { return v == value_t(ptr); }
示例#28
0
 BOOST_FORCEINLINE
   void solve(solve_qr_t const& f, A1 & a1, boost::mpl::long_<2> const&) const
 {
   boost::proto::child_c<0>(a1) = f.x();
   boost::proto::child_c<1>(a1) = value_t(f.rank());
 }
示例#29
0
 static std::vector<uint8_t> from_pv(const void *pv, size_t size) {
     auto p = reinterpret_cast<const value_t::value_type*>(pv);
     if (!p) return value_t();
     return value_t(p, p + size);
 }
示例#30
0
文件: rapid.hpp 项目: 4og/guacamole
int obb_disjoint(matrix<value_t, 3, 3> const& B,
                 point<value_t, 3> const& T,
                 point<value_t, 3> const& a,
                 point<value_t, 3> const& b) {
  register value_t t, s;
  register int r;
  value_t Bf[3][3];
  const value_t reps = value_t(1e-6);

  // Bf = fabs(B)
  Bf[0][0] = fabs(B[0][0]);
  Bf[0][0] += reps;
  Bf[0][1] = fabs(B[0][1]);
  Bf[0][1] += reps;
  Bf[0][2] = fabs(B[0][2]);
  Bf[0][2] += reps;
  Bf[1][0] = fabs(B[1][0]);
  Bf[1][0] += reps;
  Bf[1][1] = fabs(B[1][1]);
  Bf[1][1] += reps;
  Bf[1][2] = fabs(B[1][2]);
  Bf[1][2] += reps;
  Bf[2][0] = fabs(B[2][0]);
  Bf[2][0] += reps;
  Bf[2][1] = fabs(B[2][1]);
  Bf[2][1] += reps;
  Bf[2][2] = fabs(B[2][2]);
  Bf[2][2] += reps;

  // if any of these tests are one-sided, then the polyhedra are disjoint
  r = 1;

  // A1 x A2 = A0
  t = fabs(T[0]);

  r &= (t <= (a[0] + b[0] * Bf[0][0] + b[1] * Bf[0][1] + b[2] * Bf[0][2]));
  if (!r)
    return 1;

  // B1 x B2 = B0
  s = T[0] * B[0][0] + T[1] * B[1][0] + T[2] * B[2][0];
  t = fabs(s);

  r &= (t <= (b[0] + a[0] * Bf[0][0] + a[1] * Bf[1][0] + a[2] * Bf[2][0]));
  if (!r)
    return 2;

  // A2 x A0 = A1
  t = fabs(T[1]);

  r &= (t <= (a[1] + b[0] * Bf[1][0] + b[1] * Bf[1][1] + b[2] * Bf[1][2]));
  if (!r)
    return 3;

  // A0 x A1 = A2
  t = fabs(T[2]);

  r &= (t <= (a[2] + b[0] * Bf[2][0] + b[1] * Bf[2][1] + b[2] * Bf[2][2]));
  if (!r)
    return 4;

  // B2 x B0 = B1
  s = T[0] * B[0][1] + T[1] * B[1][1] + T[2] * B[2][1];
  t = fabs(s);

  r &= (t <= (b[1] + a[0] * Bf[0][1] + a[1] * Bf[1][1] + a[2] * Bf[2][1]));
  if (!r)
    return 5;

  // B0 x B1 = B2
  s = T[0] * B[0][2] + T[1] * B[1][2] + T[2] * B[2][2];
  t = fabs(s);

  r &= (t <= (b[2] + a[0] * Bf[0][2] + a[1] * Bf[1][2] + a[2] * Bf[2][2]));
  if (!r)
    return 6;

  // A0 x B0
  s = T[2] * B[1][0] - T[1] * B[2][0];
  t = fabs(s);

  r &= (t <= (a[1] * Bf[2][0] + a[2] * Bf[1][0] + b[1] * Bf[0][2] +
              b[2] * Bf[0][1]));
  if (!r)
    return 7;

  // A0 x B1
  s = T[2] * B[1][1] - T[1] * B[2][1];
  t = fabs(s);

  r &= (t <= (a[1] * Bf[2][1] + a[2] * Bf[1][1] + b[0] * Bf[0][2] +
              b[2] * Bf[0][0]));
  if (!r)
    return 8;

  // A0 x B2
  s = T[2] * B[1][2] - T[1] * B[2][2];
  t = fabs(s);

  r &= (t <= (a[1] * Bf[2][2] + a[2] * Bf[1][2] + b[0] * Bf[0][1] +
              b[1] * Bf[0][0]));
  if (!r)
    return 9;

  // A1 x B0
  s = T[0] * B[2][0] - T[2] * B[0][0];
  t = fabs(s);

  r &= (t <= (a[0] * Bf[2][0] + a[2] * Bf[0][0] + b[1] * Bf[1][2] +
              b[2] * Bf[1][1]));
  if (!r)
    return 10;

  // A1 x B1
  s = T[0] * B[2][1] - T[2] * B[0][1];
  t = fabs(s);

  r &= (t <= (a[0] * Bf[2][1] + a[2] * Bf[0][1] + b[0] * Bf[1][2] +
              b[2] * Bf[1][0]));
  if (!r)
    return 11;

  // A1 x B2
  s = T[0] * B[2][2] - T[2] * B[0][2];
  t = fabs(s);

  r &= (t <= (a[0] * Bf[2][2] + a[2] * Bf[0][2] + b[0] * Bf[1][1] +
              b[1] * Bf[1][0]));
  if (!r)
    return 12;

  // A2 x B0
  s = T[1] * B[0][0] - T[0] * B[1][0];
  t = fabs(s);

  r &= (t <= (a[0] * Bf[1][0] + a[1] * Bf[0][0] + b[1] * Bf[2][2] +
              b[2] * Bf[2][1]));
  if (!r)
    return 13;

  // A2 x B1
  s = T[1] * B[0][1] - T[0] * B[1][1];
  t = fabs(s);

  r &= (t <= (a[0] * Bf[1][1] + a[1] * Bf[0][1] + b[0] * Bf[2][2] +
              b[2] * Bf[2][0]));
  if (!r)
    return 14;

  // A2 x B2
  s = T[1] * B[0][2] - T[0] * B[1][2];
  t = fabs(s);

  r &= (t <= (a[0] * Bf[1][2] + a[1] * Bf[0][2] + b[0] * Bf[2][1] +
              b[1] * Bf[2][0]));
  if (!r)
    return 15;

  return 0;  // should equal 0
}