static int32_t qb_validate_operands_transform(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	qb_operand *matrix1 = &operands[0], *matrix2 = &operands[1];

	if(matrix1->address->dimension_count < 2) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "matrix");
		return FALSE;
	}
	if(matrix2->address->dimension_count < 1) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 1, "vector");
		return FALSE;
	}

	if(HAS_CONSTANT_DIMENSION(matrix1->address, -2) && HAS_CONSTANT_DIMENSION(matrix1->address, -1) && HAS_CONSTANT_DIMENSION(matrix2->address, -1)) {
		qb_matrix_order order = qb_get_matrix_order(cxt, f);
		qb_address *m1_col_address = qb_obtain_matrix_column_address(cxt, matrix1->address, order);
		qb_address *m1_row_address = qb_obtain_matrix_row_address(cxt, matrix1->address, order);
		qb_address *m2_row_address = DIMENSION_ADDRESS(matrix2->address, -1);
		uint32_t m1_col_count = VALUE(U32, m1_col_address);
		uint32_t m1_row_count = VALUE(U32, m1_row_address);
		uint32_t m2_row_count = VALUE(U32, m2_row_address);

		if(!(m2_row_count >= 2 && m2_row_count <= 4 && m1_col_count == m2_row_count + 1 && m1_row_count == m2_row_count)) {
			qb_report_invalid_transform_exception(cxt->line_id, m1_col_count, m1_row_count, m2_row_count);
			return FALSE;
		}
	} else {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "matrix with fixed dimensions");
	}
	return TRUE;
}
static int32_t qb_validate_operands_array_pad(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	qb_operand *input = &operands[0], *size = &operands[1], *value = &operands[2];

	if(IS_SCALAR(input->address)) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "array");
		return FALSE;
	}
	if(!IS_SCALAR(size->address)) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "scalar");
		return FALSE;
	}

	if(input->address->dimension_count > 1) {
		qb_address *element_size_address = input->address->array_size_addresses[1];
		qb_address *value_size_address = value->address->array_size_address;
		if(IS_IMMUTABLE(element_size_address) && IS_IMMUTABLE(value_size_address)) {
			uint32_t element_size = VALUE(U32, element_size_address);
			uint32_t value_size = VALUE(U32, value_size_address);
			if(element_size != value_size) {
				qb_report_unmet_intrinsic_condition_exception(cxt->line_id, cxt->intrinsic_function, "the third parameter to have the same size as the elements in the input array");
				return FALSE;
			}
		} else {
			qb_operand guard_operands[2] = { { QB_OPERAND_ADDRESS, { value_size_address } }, { QB_OPERAND_ADDRESS, { element_size_address } } };
			qb_operand guard_result = { QB_OPERAND_EMPTY, { NULL } };
			qb_produce_op(cxt, &factory_guard_array_size_exact, guard_operands, 2, &guard_result, NULL, 0, NULL);
		}
	} else {
		if(!IS_SCALAR(value->address)) {
			qb_report_unmet_intrinsic_condition_exception(cxt->line_id, cxt->intrinsic_function, "the third parameter to be a scalar when the input array is not multidimensional");
			return FALSE;
		}
	}
	return TRUE;
}
int SimpleHinter::crossCount( const RecoResult & R, int x, int y, int W, int H )
{
    int value = VALUE( x, y );

    // go top & bottom
    int vCount = 1;
    int step = y - 1;
    while ( step >= 0 && VALUE( x, step ) == value ) {
        vCount++;
        step--;
    }
    step = y + 1;
    while ( step < H && VALUE( x, step ) == value ) {
        vCount++;
        step++;
    }

    // go right & left
    int hCount = 1;
    step = x + 1;
    while ( step < W && VALUE( step, y ) == value ) {
        hCount++;
        step++;
    }
    step = x - 1;
    while ( step >= 0 && VALUE( step, y ) == value ) {
        hCount++;
        step--;
    }

    // return the longest line
    return qMax( vCount, hCount );
}
Exemple #4
0
DefMarking(struct net_object *netobj, struct net_object *unf_netobj)
{
  struct place_object *place; 
  list curr = NULL;
  markPTR m;
  multisetPTR p_MS;
  int i;
  char *tag;
  
  while ( (curr = list_iterator(gListMarking, curr)) != NULL ){
    m = DATA(curr);
    if(m->type==0){
      evalMarking(m, &p_MS);
      for(i=0; i<CARD(p_MS) ; i++)          
        if( VALUE(SET(p_MS)[i])>0 ){        
          tag = NewStringCat(m->place->tag, STR_INDEX(SET(p_MS)[i]));      
          for(place = unf_netobj->places; place!=NULL && (strcmp(place->tag, tag)!=0) ; place = place->next);
          if(place == NULL)
            Error(UNKN_PLACE_ERR, "DefMarking", tag);
          else 
            place->m0 = VALUE(SET(p_MS)[i]);
        }
    }
    else{
      tag = NewStringCat(m->place->tag, "_");      
      for(place = unf_netobj->places; place!=NULL && (strcmp(place->tag, tag)!=0) ; place = place->next);
      if(place == NULL)
        Error(UNKN_PLACE_ERR, "DefMarking", tag);
      else 
        place->mpar = m->mrk;
    }
  }


}
Exemple #5
0
// TODO : Fix it. Transaction abort clears transaction log buffer resulting in resetting transaction ID.
TEST_F(NLDBTest, transaction_abort) {

	ASSERT_TRUE( nldb_tx_begin(tx) == 0 );

	ASSERT_TRUE( nldb_table_put( tx, vol_table, KEY(rec1), VALUE(rec1) ) == 0 );

	ASSERT_TRUE( nldb_tx_commit(tx) == 0 );

	ASSERT_TRUE( nldb_tx_begin(tx) == 0 );

	// Put the value with rec2 temporarily.
	ASSERT_TRUE( nldb_table_put( tx, vol_table, KEY(rec1), VALUE(rec2) ) == 0 );

	// Check before abort
	{
		nldb_value_t v;
		ASSERT_TRUE( nldb_table_get( tx, vol_table, KEY(rec1), & v, NULL /*nldb_order_t*/) == 0 );
		// The value should be rec2
		ASSERT_TRUE( IS_VALUE_EQUAL(rec2, v));
	}
	ASSERT_TRUE( nldb_tx_abort(tx) == 0 );

	// Check value after abort
	{
		nldb_value_t v;
		ASSERT_TRUE( nldb_table_get( tx, vol_table, KEY(rec1), & v, NULL /*nldb_order_t*/ ) == 0 );
		// The value should be rec1 after aborting the transaction.
		ASSERT_TRUE( IS_VALUE_EQUAL(rec1, v));
	}

}
Exemple #6
0
void
s3b_hash_remove(struct s3b_hash *hash, s3b_block_t key)
{
    u_int i;
    u_int j;
    u_int k;

    /* Find entry */
    for (i = FIRST(hash, key); 1; i = NEXT(hash, i)) {
        void *const value = VALUE(hash, i);

        if (EMPTY(value))               /* no such entry */
            return;
        if (KEY(value) == key)          /* entry found */
            break;
    }

    /* Repair subsequent entries as necessary */
    for (j = NEXT(hash, i); 1; j = NEXT(hash, j)) {
        void *const value = VALUE(hash, j);

        if (value == NULL)
            break;
        k = FIRST(hash, KEY(value));
        if (j > i ? (k <= i || k > j) : (k <= i && k > j)) {
            VALUE(hash, i) = value;
            i = j;
        }
    }

    /* Remove entry */
    assert(VALUE(hash, i) != NULL);
    VALUE(hash, i) = NULL;
    hash->numkeys--;
}
static int32_t qb_validate_operands_vm_mult(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	qb_operand *matrix1 = &operands[0], *matrix2 = &operands[1];
	qb_matrix_order order = qb_get_matrix_order(cxt, f);
	qb_address *m1_col_address = DIMENSION_ADDRESS(matrix1->address, -1);
	qb_address *m2_row_address = qb_obtain_matrix_row_address(cxt, matrix2->address, order);

	if(matrix1->address->dimension_count < 1) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "vector");
		return FALSE;
	}
	if(matrix2->address->dimension_count < 2) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 1, "matrix");
		return FALSE;
	}

	if(m1_col_address != m2_row_address) {
		if(IS_IMMUTABLE(m1_col_address) && IS_IMMUTABLE(m2_row_address)) {
			uint32_t m1_col_count = VALUE(U32, m1_col_address);
			uint32_t m2_row_count = VALUE(U32, m2_row_address);

			if(!cxt->matrix_padding) {
				if(m1_col_count != m2_row_count) {
					qb_report_invalid_matrix_multiplication_exception(cxt->line_id, m1_col_count, m2_row_count, 2);
					return FALSE;
				}
			}
		} else {
			qb_operand operands[2] = { { QB_OPERAND_ADDRESS, { m1_col_address } }, { QB_OPERAND_ADDRESS, { m2_row_address } } };
			qb_produce_op(cxt, &factory_validate_vm_mult, operands, 2, NULL, NULL, 0, NULL);
		}
	}
	return TRUE;
}
Exemple #8
0
static void
value_finalize (GObject *gobject)
{
	g_free(VALUE (gobject)->dictkeyword);
	g_free(VALUE (gobject)->value);

	//G_OBJECT_CLASS (gobject)->finalize (gobject);
}
Exemple #9
0
static void
ct_swap_data(node_t *node1, node_t *node2)
{
	PyObject *tmp;
	tmp = KEY(node1);
	KEY(node1) = KEY(node2);
	KEY(node2) = tmp;
	tmp = VALUE(node1);
	VALUE(node1) = VALUE(node2);
	VALUE(node2) = tmp;
}
Exemple #10
0
P op_errormessage(void)
{
  LBIG e, pid, port;
  P nb, tnb; 
  B *m, *s;

  if (o_6 < FLOORopds) goto baderror;
  if (CLASS(o_6) != NUM) goto baderror;
  if (! VALUE(o_6, &pid)) goto baderror;
  if (TAG(o_5) != (ARRAY | BYTETYPE)) goto baderror;
  if (CLASS(o_4) != NUM) goto baderror;
  if (! VALUE(o_4, &port)) goto baderror;
  if (TAG(o_3) != (ARRAY | BYTETYPE)) goto baderror;
  if (CLASS(o_2) != NUM) goto baderror;
  if (!VALUE(o_2, &e)) goto baderror;
  if (TAG(o_1) != (ARRAY | BYTETYPE)) goto baderror;

  s = (B *)VALUE_BASE(o_1); 
  tnb = ARRAY_SIZE(o_1);
  nb = dm_snprintf((char*) s, tnb, "On %*s port %llu, pid %llu: ",
		   (int) ARRAY_SIZE(o_5),
		   (char*) VALUE_BASE(o_5),
                   (unsigned long long) port,
		   (unsigned long long) pid);
  s += nb;
  tnb -= nb;

  if ((P)e < 0) /*Clib error */
    nb = dm_snprintf((char*) s, tnb, "errno: %s",
		     (char*) strerror(-(int)e));
  else { /* one of our error codes: decode */
    m = geterror((P) e);
    nb = strlen((char*) m);
    if (nb > tnb) nb = tnb;
    moveB(m, s, nb);
  }
  s += nb;
  tnb -= nb;

  nb = dm_snprintf((char*)s, tnb, " in %*s\n",
		   (int) ARRAY_SIZE(o_3),
		   (char*) VALUE_BASE(o_3));

  ARRAY_SIZE(o_1) = (P)(s + nb) - VALUE_BASE(o_1);
  moveframe(o_1,o_6);
  FREEopds = o_5;
  return OK;

 baderror:
  printf("**Error with corrupted error info on operand stack!\n");
  return op_halt();
}
Exemple #11
0
void* _omFindInSortedList(void* list, int next, int long_field,
                          unsigned long what)
{
  while (list != NULL)
  {
    if (VALUE(list, long_field) >= what)
    {
      if (VALUE(list, long_field) == what) return list;
      return NULL;
    }
    ITER(list);
  }
  return NULL;
}
Exemple #12
0
/* Return the product of two expressions */
static exp_t *
prod(exp_t *a1, exp_t *a2)
{
        exp_t *res;

        CHKNUM(a1, *);
        CHKNUM(a2, *);

        if (isfloat(a1) || isfloat(a2))
                res = nfloat(VALUE(a1) * VALUE(a2));
        else
                res = nrat(NUMER(a1) * NUMER(a2), DENOM(a1) * DENOM(a2));
        return res;
}
Exemple #13
0
void dl_print(List list) {
    assert_argument_not_null(list);
    dl_assert_element_size(list);
    ListNode *node = list->first;
    printf("[");
    if (node != NULL) {
        printf("%g", VALUE(node));
        node = node->next;
    }
    for (; node != NULL; node = node->next) {
        printf(", %g", VALUE(node));
    }
    printf("]");
}
Exemple #14
0
void _stdcall AddDebugAlloc(void* pPointer, int nSize)
{
	VALUE(vProgInfo);
	LPDBGALLOCINFO pDbg;	
	char *pProgInfo = 0;

	if (pPointer && gbTrackAlloc)
	{
		pDbg = malloc(sizeof(DBGALLOCINFO));
		if (!pDbg)
			return;

		EVALUATE(vProgInfo,"ALLTRIM(STR(LINENO())) + ':' + PROGRAM() + CHR(0)");
		if (IS_STRING(vProgInfo))
		{
			pProgInfo = strdup(HANDTOPTR(vProgInfo));
			FREEHAND(vProgInfo);
		}

		pDbg->pPointer = pPointer;
		pDbg->pProgInfo = pProgInfo;
		pDbg->nSize = nSize;
		pDbg->next = gpDbgInfo;
		gpDbgInfo = pDbg;
	}
}
Exemple #15
0
static void
print_dist (gsl_monte_vegas_state * state, unsigned long dim)
{
  unsigned long i, j;
  int p = state->verbose;
  if (p < 1)
    return;

  for (j = 0; j < dim; ++j)
    {
      fprintf (state->ostream, "\n axis %lu \n", j);
      fprintf (state->ostream, "      x   g\n");
      for (i = 0; i < state->bins; i++)
        {
          fprintf (state->ostream, "weight [%11.2e , %11.2e] = ", 
                   COORD (state, i, j), COORD(state,i+1,j));
          fprintf (state->ostream, " %11.2e\n", VALUE (state, i, j));

        }
      fprintf (state->ostream, "\n");
    }
  fprintf (state->ostream, "\n");
  fflush (state->ostream);

}
Exemple #16
0
 List* Prepend( VALUE v ) final {
     auto c = Cons::Create(v, VALUE(this));
     //std::cout << "\nBefore:" << LIST(TList,this).Print();
     //std::cout << "\nPrepended:" << v.Print();
     //std::cout << "\nAfter:" << LIST(TList,c).Print() << "\n";
     return c;
 }
Exemple #17
0
/* Return the division of two expressions */
static exp_t *
divs(exp_t *a1, exp_t *a2)
{
        exp_t *res;

        CHKNUM(a1, /);
        CHKNUM(a2, /);

        if (VALUE(a2) == 0)
                everr("/: argument is divided by zero", a1);
        if (isfloat(a1) || isfloat(a2))
                res = nfloat(VALUE(a1) / VALUE(a2));
        else
                res = nrat(NUMER(a1) * DENOM(a2), NUMER(a2) * DENOM(a1));
        return res;
}
static GCC_INLINE void fc_pro_get_board(long gamenumber, Position * pos)
{
    int  i, j;                /*  generic counters */
    int  wLeft = 52;          /*  cards left to be chosen in shuffle */
    CARD deck[52];            /* deck of 52 unique cards */
    int col;
    CARD card, suit;

    memset(pos, '\0', sizeof(*pos));

    /* shuffle cards */

    for (i = 0; i < 52; i++)      /* put unique card in each deck loc. */
    {
        deck[i] = i;
    }

    for (i = 0; i < 52; i++)
    {
        j = microsoft_rand_rand(&gamenumber) % wLeft;
        col = (i%8);
        card = deck[j];
        suit = SUIT(card);
        pos->tableau[col].cards[pos->tableau[col].count++]
            = (Card)((VALUE(card)+1)
            + (((suit == 3) ? suit : ((suit+1)%3))<<4))
            ;
        deck[j] = deck[--wLeft];
    }
}
Exemple #19
0
static void
ct_delete_node(node_t *node)
{
	Py_XDECREF(KEY(node));
	Py_XDECREF(VALUE(node));
	PyMem_Free(node);
}
Exemple #20
0
void _stdcall ReplaceDebugAlloc(void* pOrig, void* pNew, int nSize)
{
	LPDBGALLOCINFO pDbg = gpDbgInfo;
	VALUE(vProgInfo);
	char* pProgInfo = 0;

	if (!pNew || !gbTrackAlloc)
		return;
    
	while (pDbg && pDbg->pPointer != pOrig)
		pDbg = pDbg->next;

    if (pDbg)
	{
		EVALUATE(vProgInfo,"ALLTRIM(STR(LINENO())) + ':' + PROGRAM() + CHR(0)");
		if (IS_STRING(vProgInfo))
		{
			pProgInfo = strdup(HANDTOPTR(vProgInfo));
			FREEHAND(vProgInfo);
		}

		if (pDbg->pProgInfo)
			free(pDbg->pProgInfo);

		pDbg->pPointer = pNew;
		pDbg->pProgInfo = pProgInfo;
		pDbg->nSize = nSize;
	}
}
Exemple #21
0
    // Override of the List interface
    List* Append( VALUE elem ) {
#ifdef USE_CONS_OPTIMIZATIONS
        List* tail = this;
        while (!tail->Rest().IsEmpty() ) {
            tail = tail->Rest().GetList();
        }
        if (tail->RefCount < 2 && tail->Rest().IsEmpty()) {
            // We can optimize things as we can reuse this materalization.
            // Nobody is referencing it.
            if (tail->AttemptDirtyAdd(elem)) {
                return this;
            };
        }
#endif
        int originalCount = Count();
        int last = Count()-1;
        List* c = VALUE(QParenthesis,elem).GetList();
        while (last >= 0) {
            c = c->Prepend( GetAt(last) );
            last--;
        }
        int newCount = c->Count();
        assert( newCount == originalCount + 1 );
//        std::cout << "\nBefore:" << LIST(this).Print();
//        std::cout << "\nAdded:" << elem.Print();
//        std::cout << "\nAfter:" << LIST(c).Print() << "\n";
        return c;
    }
static int32_t qb_validate_operands_array_push(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	qb_operand *container = &operands[0];
	qb_address *container_element_size_address;
	uint32_t i;

	if(IS_TEMPORARY(container->address)) {
		qb_report_unexpected_value_as_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0);
		return FALSE;
	}
	if(IS_SCALAR(container->address)) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "array");
		return FALSE;
	}
	if(IS_FIXED_LENGTH(container->address)) {
		qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, 0, "variable-length array");
		return FALSE;
	}

	if(container->address->dimension_count > 1) {
		container_element_size_address = container->address->array_size_addresses[1];
	} else {
		container_element_size_address = cxt->one_address;
	}

	// make sure the elements being pushed in match the size of the elements in the container
	for(i = 1; i < operand_count; i++) {
		qb_address *address = operands[i].address;
		qb_address *element_size_address = address->array_size_address;

		if(container_element_size_address != element_size_address) {
			if(IS_IMMUTABLE(container_element_size_address) && IS_IMMUTABLE(element_size_address)) {
				uint32_t container_element_size = VALUE(U32, container_element_size_address);
				uint32_t element_size = VALUE(U32, element_size_address);
				if(container_element_size != element_size) {
					qb_report_unmet_intrinsic_condition_exception(cxt->line_id, cxt->intrinsic_function, "values of the same size as the elements in the container");
					return FALSE;
				}
			} else {
				qb_operand guard_operands[2] = { { QB_OPERAND_ADDRESS, { element_size_address } }, { QB_OPERAND_ADDRESS, { container_element_size_address } } };
				qb_operand guard_result = { QB_OPERAND_EMPTY, { NULL } };
				qb_produce_op(cxt, &factory_guard_array_size_exact, guard_operands, 2, &guard_result, NULL, 0, NULL);
			}
		}
	}
	return TRUE;
}
Exemple #23
0
static void check_blocks(void)
{
    for (uint32_t n=0; n<nblocks; n++) {
        for (uint32_t i=0; i<sizeof(blocks[nblocks]->v)/sizeof(uint32_t); i++) {
            assert(blocks[n]->v[i] == VALUE(i));
        }
    }
}
void set_vars(int step)
{
    int n, i;
    int v = VALUE(subrank, step);

    n = ldim1;
    for (i=0; i<n; i++) a1[i] = v;
}
Exemple #25
0
/*
 * Optimization of s3b_hash_put() for when it is known that no matching entry exists.
 */
void
s3b_hash_put_new(struct s3b_hash *hash, void *value)
{
    const s3b_block_t key = KEY(value);
    u_int i;

    for (i = FIRST(hash, key); 1; i = NEXT(hash, i)) {
        void *const value2 = VALUE(hash, i);

        if (EMPTY(value2))
            break;
        assert(KEY(value2) != key);
    }
    assert(hash->numkeys < hash->maxkeys);
    VALUE(hash, i) = value;
    hash->numkeys++;
}
Exemple #26
0
/* Return the difference of two expressions */
static exp_t *
sub(exp_t *a1, exp_t *a2)
{
        long n1, n2, d1, d2;
        exp_t *res;

        CHKNUM(a1, -);
        CHKNUM(a2, -);

        if (isfloat(a1) || isfloat(a2))
                res = nfloat(VALUE(a1) - VALUE(a2));
        else {
                n1 = NUMER(a1), n2 = NUMER(a2);
                d1 = DENOM(a1), d2 = DENOM(a2);
                res = nrat(n1*d2 - n2*d1, d1 * d2);
        }
        return res;
}
Exemple #27
0
static void
value_get_property (GObject    *gobject,
		   guint       prop_id,
		   GValue     *value,
		   GParamSpec *pspec)
{
	switch (prop_id)
	{
	case PROP_DICTIONARY_KEYWORD:
		g_value_set_string (value, VALUE (gobject)->dictkeyword);
		break;
	case PROP_VALUE:
		g_value_set_string (value, VALUE (gobject)->value);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
	}
}
Exemple #28
0
double dl_next(ListIterator *iter) {
    if (*iter == NULL) {
        printf("%s: iterator does not have a next value\n", __func__);
        exit(EXIT_FAILURE);
    }
    double value = VALUE(*iter);
    *iter = (*iter)->next;
    return value;
}
Exemple #29
0
/* take a _node_t, value, and depth (zero means root) */
_node_t *_find(_node_t *o, uint32_t v, size_t d) {
  if (_is_leaf(o)) {
    return VALUE(o) == v ? o : NULL;
  }
  if (!_has_children(o)) {
    return NULL;
  }
  return _find(_children(o) + _idx8(v, d), v, d + 1);
}
static int32_t qb_validate_operands_cross_product(qb_compiler_context *cxt, qb_op_factory *f, qb_primitive_type expr_type, uint32_t flags, qb_operand *operands, uint32_t operand_count, qb_result_destination *result_destination) {
	uint32_t i;

	for(i = 0; i < operand_count; i++) {
		qb_operand *operand = &operands[0];
		if(IS_SCALAR(operand->address)) {
			qb_report_unexpected_intrinsic_argument_exception(cxt->line_id, cxt->intrinsic_function, i, "array");
			return FALSE;
		}
	}

	if(operand_count == 3) {
		qb_operand *operand1 = &operands[0], *operand2 = &operands[1], *operand3 = &operands[2];
		qb_address *v1_width_address = DIMENSION_ADDRESS(operand1->address, -1);
		qb_address *v2_width_address = DIMENSION_ADDRESS(operand2->address, -1);
		qb_address *v3_width_address = DIMENSION_ADDRESS(operand3->address, -1);
		if(IS_IMMUTABLE(v1_width_address) && IS_IMMUTABLE(v2_width_address) && IS_IMMUTABLE(v3_width_address)) {
			uint32_t v1_width = VALUE(U32, v1_width_address);
			uint32_t v2_width = VALUE(U32, v2_width_address);
			uint32_t v3_width = VALUE(U32, v3_width_address);

			if(!(v1_width == v2_width && v2_width == v3_width && v1_width == 4)) {
				qb_report_invalid_4d_cross_product_exception(cxt->line_id, v1_width, v2_width, v3_width);
				return FALSE;
			}
		} else {
			qb_operand operands[3] = { { QB_OPERAND_ADDRESS, { v1_width_address } }, { QB_OPERAND_ADDRESS, { v2_width_address } }, { QB_OPERAND_ADDRESS, { v3_width_address } } };
			qb_produce_op(cxt, &factory_validate_cross_product_4d, operands, 3, NULL, NULL, 0, NULL);
		} 
	} else {
		qb_operand *operand1 = &operands[0], *operand2 = &operands[1];
		qb_address *v1_width_address = DIMENSION_ADDRESS(operand1->address, -1);
		qb_address *v2_width_address = DIMENSION_ADDRESS(operand2->address, -1);
		if(IS_IMMUTABLE(v1_width_address) && IS_IMMUTABLE(v2_width_address)) {
			uint32_t v1_width = VALUE(U32, v1_width_address);
			uint32_t v2_width = VALUE(U32, v2_width_address);

			if(!(v1_width == v2_width && 2 <= v1_width && v2_width <= 3)) {
				qb_report_invalid_cross_product_exception(cxt->line_id, v1_width, v2_width);
				return FALSE;
			}
		} else {
			qb_operand operands[2] = { { QB_OPERAND_ADDRESS, { v1_width_address } }, { QB_OPERAND_ADDRESS, { v2_width_address } } };
			uint32_t width = 3;
			if(IS_IMMUTABLE(v1_width_address)) {
				width = VALUE(U32, v1_width_address);
			}
			if(IS_IMMUTABLE(v2_width_address)) {
				width = VALUE(U32, v2_width_address);
			}
			if(width == 2) {
				qb_produce_op(cxt, &factory_validate_cross_product_2d, operands, 2, NULL, NULL, 0, NULL);
			} else {
				qb_produce_op(cxt, &factory_validate_cross_product_3d, operands, 2, NULL, NULL, 0, NULL);
			}
		} 
	}
	return TRUE;
}