Beispiel #1
0
int
Semantic::cp(String &andor, Array<List<Semantic * > > &asubc, 
		Array<List<Semantic * > > &asubx) const
{
	// check the type of record
	if (isPredicate())
	{
		return(none(andor, asubc, asubx, "cp", "%p0"));
	}
	else if (isExpression())
	{
		switch (type)
		{
		case Conditional:
			return(cp_conditional(andor, asubc, asubx, "cp"));
		case Biconditional:
			return(cp_biconditional(andor, asubc, asubx, "cp"));
		default:
			return(none(andor, asubc, asubx, "cp", "%p0"));
		}
	}

	// all done
	ERRORD("contrapositive called with wrong type.", type, EINVAL);
	return(NOTOK);
}
Beispiel #2
0
int
Semantic::schaum(String &andor, Array<List<Semantic * > > &asubc, 
		Array<List<Semantic * > > &asubx) const
{
	// check the type of record
	if (isPredicate())
	{
		return(none(andor, asubc, asubx, "schaum", "%p0"));
	}
	else if (isExpression())
	{
		switch (type)
		{
		case And:
			return(schaum_and(andor, asubc, asubx, "schaum"));
		case Or:
			return(schaum_or(andor, asubc, asubx, "schaum"));
		case Conditional:
			return(schaum_conditional(andor, asubc, asubx, "schaum"));
		case Biconditional:
			return(schaum_biconditional(andor, asubc, asubx, "schaum"));
		default:
			return(none(andor, asubc, asubx, "schaum", "%p0"));
		}
	}

	// all done
	ERRORD("schaum called with wrong type.", type, EINVAL);
	return(NOTOK);
}
Beispiel #3
0
int
w_debug::flag_on(
    const char *fn,
    const char *file
)
{
    int res = 0;
    assert( !( none() && all() ) );
    if(_flags==nullptr) {
    res = 0; //  another constructor called this
            // before this's constructor got called.
    } else if(none())     {
    res = 0;
    } else if(all())     {
    res = 1;
#ifdef USE_REGEX
    } else  if(file && re_exec_debug(file)) {
    res = 1;
    } else if(fn && re_exec_debug(fn)) {
    res = 1;
#endif /* USE_REGEX */
    } else
    // if the regular expression didn't match,
    // try searching the strings
    if(file && strstr(_flags,file)) {
    res = 1;
    } else if(fn && strstr(_flags,fn)) {
    res = 1;
    }
    return res;
}
Beispiel #4
0
 tendril::tendril()
   : doc_()
   , flags_()
   , converter(&ConverterImpl<none>::instance)
 {
   set_holder<none>(none());
 }
// @Override
ECode CWifiInfo::ToString(
    /* [out] */ String* str)
{
    StringBuffer sb;
    String none("<none>");

    sb.Append("SSID: ");
    String sidStr;
    mWifiSsid->ToString(&sidStr);
    sb.Append(mWifiSsid == NULL ? IWifiSsid::NONE : sidStr);
    sb.Append(", BSSID: ");
    sb.Append(mBSSID.IsNull() ? none : mBSSID);
    sb.Append(", MAC: ");
    sb.Append(mMacAddress.IsNull() ? none : mMacAddress);
    sb.Append(", Supplicant state: ");
    if (mSupplicantState == NULL) sb.Append(none);
    sb.Append(mSupplicantState);
    sb.Append(", RSSI: ");
    sb.Append(mRssi);
    sb.Append(", Link speed: ");
    sb.Append(mLinkSpeed);
    sb.Append(", Net ID: ");
    sb.Append(mNetworkId);
    sb.Append(", Metered hint: ");
    sb.AppendBoolean(mMeteredHint);

    *str = sb.ToString();
    return NOERROR;
}
Beispiel #6
0
ClosestPolygonPoint findClosest(Point from, Polygons& polygons)
{

    Polygon emptyPoly;
    ClosestPolygonPoint none(from, -1, emptyPoly);
    
    if (polygons.size() == 0) return none;
    PolygonRef aPolygon = polygons[0];
    if (aPolygon.size() == 0) return none;
    Point aPoint = aPolygon[0];

    ClosestPolygonPoint best(aPoint, 0, aPolygon);

    int64_t closestDist = vSize2(from - best.location);
    
    for (unsigned int ply = 0; ply < polygons.size(); ply++)
    {
        PolygonRef poly = polygons[ply];
        if (poly.size() == 0) continue;
        ClosestPolygonPoint closestHere = findClosest(from, poly);
        int64_t dist = vSize2(from - closestHere.location);
        if (dist < closestDist)
        {
            best = closestHere;
            closestDist = dist;
        }

    }

    return best;
}
Beispiel #7
0
static PyObject *qdbpy_multiread(QdbHandle *self, PyObject *args)
{
    qdb_handle_t qdb;
    char *path;

    char **values;
    unsigned int list_len;
    unsigned int *values_len;

    if (!parse_handle_path(self, args, &qdb, &path))
        return NULL;

    Py_BEGIN_ALLOW_THREADS
    values = qdb_multiread(qdb, path, &values_len, &list_len);
    Py_END_ALLOW_THREADS

    if (values) {
        int i;
        PyObject *val = PyDict_New();
        for (i = 0; i < list_len; i++) {
            PyDict_SetItemString(val,
                    values[2*i],
                    PyString_FromStringAndSize(values[2*i+1], values_len[i]));
            free(values[2*i]);
            free(values[2*i+1]);
        }
        free(values);
        free(values_len);
        return val;
    }
    else {
        return none(errno == ENOENT);
    }
}
Beispiel #8
0
static PyObject *qdbpy_list(QdbHandle *self, PyObject *args)
{
    qdb_handle_t qdb;
    char *path;

    char **list;
    unsigned int list_len;

    if (!parse_handle_path(self, args, &qdb, &path))
        return NULL;

    Py_BEGIN_ALLOW_THREADS
    list = qdb_list(qdb, path, &list_len);
    Py_END_ALLOW_THREADS

    if (list) {
        int i;
        PyObject *val = PyList_New(list_len);
        for (i = 0; i < list_len; i++) {
            PyList_SetItem(val, i, PyString_FromString(list[i]));
            free(list[i]);
        }
        free(list);
        return val;
    }
    else {
        return none(errno == ENOENT);
    }
}
Beispiel #9
0
void
w_debug::setflags(const char *newflags)
{
    if(!newflags) return;
#ifdef USE_REGEX
    {
        char *s;
        if((s=re_comp_debug(newflags)) != 0) {
            cerr << "Error in regex, flags not set: " <<  s << endl;
            mask = _none;
            return;
        }
    }
#endif /* USE_REGEX */

    mask = 0;
    if(_flags) delete []  _flags;
    _flags = new char[strlen(newflags)+1];
    strcpy(_flags, newflags);
    if(strlen(_flags)==0) {
        mask |= _none;
    } else if(!strcmp(_flags,"all")) {
        mask |= _all;
    }
    assert( !( none() && all() ) );
}
Beispiel #10
0
// split problems
int
Semantic::split(const String &rtype, String &andor, 
		Array<List<Semantic * > > &asubc, 
		Array<List<Semantic * > > &asubx) const
{
	// check if we reducing the correct types
	if (!isExpression() && !isPredicate())
		return(NOTOK);

	// determine reducing strategy
	if (rtype == String("bledsoe"))
	{
		return(bledsoe(andor, asubc, asubx));
	}
	else if (rtype == String("schaum"))
	{
		return(schaum(andor, asubc, asubx));
	}
	else if (rtype == String("cp"))
	{
		return(cp(andor, asubc, asubx));
	}
	else if (rtype == String("none"))
	{
		return(none(andor, asubc, asubx, "none", "%p0"));
	}
	else
	{
		ERRORD("invalid reduction type", rtype, EINVAL);
		return(NOTOK);
	}
}
std::string
ModelEvaluatorBase::DerivativeSupport::description() const
{
  std::ostringstream oss;
  oss << "DerivativeSupport{";
  if (none()) {
    oss << "none";
  }
  else {
    bool wroteOutput = false;
    if (supportsLinearOp_) {
      oss << "DERIV_LINEAR_OP";
      wroteOutput = true;
    }
    if (supportsMVByCol_) {
      oss << (wroteOutput?",":"") << toString(DERIV_MV_BY_COL);
      wroteOutput = true;
    }
    if (supportsTransMVByRow_) {
      oss << (wroteOutput?",":"") << toString(DERIV_TRANS_MV_BY_ROW);
      wroteOutput = true;
    }
  }
  oss << "}";
  return oss.str();
}
Beispiel #12
0
PyObject * listToDoubleArray(PyObject *list_obj, double *arr, unsigned n) {
	PyObject *item, *f_item;
	unsigned pylist_len = (unsigned) PyList_Size(list_obj);
	unsigned i;
	if (pylist_len != n) {
		PyErr_SetString(PyExc_IndexError, "list index out of range");
		return 0L;
	}
	for (i = 0; i < n; ++i) {
		item = PyList_GetItem(list_obj, i);
		if (item == 0L) {
			return 0L;
		}
		Py_INCREF(item);
		f_item = PyNumber_Float(item);
		if (f_item == 0L) {
			Py_DECREF(item);
			return 0L;
		}
		arr[i] = PyFloat_AsDouble(item);
		Py_DECREF(item);
		Py_DECREF(f_item);
	}
	return none();
}
Beispiel #13
0
PyObject * tupleToDoubleMatrix(PyObject *tuple_obj, double **arr, unsigned n_rows, unsigned n_cols, int demandExactLen) {
	PyObject *item, *r_item;
	unsigned pytuple_len = (unsigned) PyTuple_Size(tuple_obj);
	unsigned i;
	if (pytuple_len != n_rows && ((demandExactLen != 0) || (pytuple_len < n_rows))) {
		PyErr_SetString(PyExc_IndexError, "tuple index out of range");
		return 0L;
	}
	for (i = 0; i < n_rows; ++i) {
		item = PyTuple_GetItem(tuple_obj, i);
		if (item == 0L) {
			return 0L;
		}
		Py_INCREF(item);
		if (!PyTuple_Check(item)) {
			PyErr_SetString(PyExc_TypeError, "tuple of tuple of floats expected");
			Py_DECREF(item);
			return 0L;
		}
		r_item = tupleToDoubleArray(item, arr[i], n_cols, demandExactLen);
		Py_DECREF(item);
		if (0L == r_item)
			return 0L;
	}
	return none();
}
Beispiel #14
0
PyObject * listToDoubleMatrix(PyObject *list_obj, double **arr, unsigned n_rows, unsigned n_cols) {
	PyObject *item, *r_item;
	unsigned pylist_len = (unsigned) PyList_Size(list_obj);
	unsigned i;
	if (pylist_len != n_rows) {
		PyErr_SetString(PyExc_IndexError, "list index out of range");
		return 0L;
	}
	for (i = 0; i < n_rows; ++i) {
		item = PyList_GetItem(list_obj, i);
		if (item == 0L) {
			return 0L;
		}
		Py_INCREF(item);
		if (!PyList_Check(item)) {
			PyErr_SetString(PyExc_TypeError, "list of list of floats expected");
			Py_DECREF(item);
			return 0L;
		}
		r_item = listToDoubleArray(item, arr[i], n_cols);
		Py_DECREF(item);
		if (0L == r_item)
			return 0L;
	}
	return none();
}
Beispiel #15
0
PyObject * tupleToDoubleArray(PyObject *tuple_obj, double *arr, unsigned n, int demandExactLen) {
	PyObject *item, *f_item;
	unsigned pytuple_len = (unsigned) PyTuple_Size(tuple_obj);
	unsigned i;
	if (pytuple_len != n && ((demandExactLen != 0) || (pytuple_len < n))) {
		PyErr_SetString(PyExc_IndexError, "tuple index out of range");
		return 0L;
	}
	for (i = 0; i < n; ++i) {
		item = PyTuple_GetItem(tuple_obj, i);
		if (item == 0L) {
			return 0L;
		}
		Py_INCREF(item);
		f_item = PyNumber_Float(item);
		if (f_item == 0L) {
			Py_DECREF(item);
			return 0L;
		}
		arr[i] = PyFloat_AsDouble(item);
		Py_DECREF(item);
		Py_DECREF(f_item);
	}
	return none();
}
void FilterGeneratorGUI::fillComboBoxes()
{
	QString gen("Generic");
	QMap<QString,MeshFilterInterface::FilterClass> category;
	MeshLabFilterInterface::initConvertingCategoryMap(category);
	for(QMap<QString,MeshFilterInterface::FilterClass>::iterator it = category.begin();it != category.end();++it)
	{

		if (it.key() != gen)
			ui->category->addItem(it.key());
		else
			ui->category->setDefaultValue(gen);
	}

	QString none("MM_NONE");
	QMap<QString,MeshModel::MeshElement> element;
	MeshLabFilterInterface::initConvertingMap(element);
	for(QMap<QString,MeshModel::MeshElement>::iterator it = element.begin();it != element.end();++it)
	{
		if (it.key() != none)
		{
			ui->precond->addItem(it.key());
			ui->postcond->addItem(it.key());
		}
		else
		{
			ui->precond->setDefaultValue(none);
			ui->postcond->setDefaultValue(none);
		}
	}

	ui->arity->addItem(MLXMLElNames::singleMeshArity);
	ui->arity->addItem(MLXMLElNames::fixedArity);
	ui->arity->addItem(MLXMLElNames::variableArity);
}
Beispiel #17
0
void KQtTester::testImageEffects()
{
    QString report = QString("execute %1 times:\n").arg(g_nTimes);

    report += QString("none:\t%1\tms\n").arg(none());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("gray:\t%1\tms\n").arg(gray());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("watermark:\t%1\tms\n").arg(watermark());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("bilevel:\t%1\tms\n").arg(bilevel());

    m_pPainter->resetMatrix();
    m_pPainter->translate(0, g_img.height() + 10);
    report += QString("lightBlue:\t%1\tms\n").arg(lightBlue());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("darkBlue:\t%1\tms\n").arg(darkBlue());

    m_pPainter->resetMatrix();
    m_pPainter->translate(0, (g_img.height() + 10) * 2);
    report += QString("colorKey:\t%1\tms\n").arg(colorKey());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("brightness:\t%1\tms\n").arg(brightness());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("contrast:\t%1\tms\n").arg(contrast());
    m_pPainter->translate(g_img.width() + 10, 0);
    report += QString("brown:\t%1\tms\n").arg(brown());

	drawReport(report);
}
Beispiel #18
0
maybe_t<redirection_type_t> redirection_type_for_string(const wcstring &str, int *out_fd) {
    auto v = read_redirection_or_fd_pipe(str.c_str());
    // Redirections only, no pipes.
    if (!v || v->type != TOK_REDIRECT || v->fd < 0) return none();
    if (out_fd) *out_fd = v->fd;
    return v->redirection_mode;
}
Beispiel #19
0
 ModEvent
 BoolVarImp::zero_none(Space& home) {
   assert(none());
   bits() ^= (NONE ^ ZERO);
   assert(zero());
   IntDelta d(1);
   return notify(home,ME_BOOL_VAL,d);
 }
Beispiel #20
0
    gc::handle<value> lookup(ast_variable const& var) const {
        const_iterator it = find(var);
        if (end() != it) {
            return it->second;
        }

        return !!parent() ? parent()->lookup(var) : none();
    }
Beispiel #21
0
 ModEvent
 BoolVarImp::one_none(Space& home) {
   assert(none());
   bits() ^= (NONE ^ ONE);
   assert(one());
   IntDelta d(0);
   return notify(home,ME_BOOL_VAL,d);
 }
  void SubdivMeshAVX::interpolateN(const void* valid_i, const unsigned* primIDs, const float* u, const float* v, size_t numUVs, 
                                   RTCBufferType buffer, float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, size_t numFloats)
  {
#if defined(DEBUG)
    if ((parent->aflags & RTC_INTERPOLATE) == 0) 
      throw_RTCError(RTC_INVALID_OPERATION,"rtcInterpolate can only get called when RTC_INTERPOLATE is enabled for the scene");
#endif

    const int* valid = (const int*) valid_i;
    
    for (size_t i=0; i<numUVs;) 
    {
      if (i+4 >= numUVs)
      {
        vbool4 valid1 = vint4(int(i))+vint4(step) < vint4(numUVs);
        if (valid) valid1 &= vint4::loadu(&valid[i]) == vint4(-1);
        if (none(valid1)) { i+=4; continue; }
        interpolateHelper(valid1,vint4::loadu(&primIDs[i]),vfloat4::loadu(&u[i]),vfloat4::loadu(&v[i]),numUVs,buffer, 
                          P ? P+i : nullptr, 
                          dPdu ? dPdu+i : nullptr, 
                          dPdv ? dPdv+i : nullptr,
                          ddPdudu ? ddPdudu+i : nullptr,
                          ddPdvdv ? ddPdvdv+i : nullptr,
                          ddPdudv ? ddPdudv+i : nullptr,
                          numFloats);
        i+=4;
      }
      else
      {
        vbool8 valid1 = vint8(int(i))+vint8(step) < vint8(int(numUVs));
        if (valid) valid1 &= vint8::loadu(&valid[i]) == vint8(-1);
        if (none(valid1)) { i+=8; continue; }
        interpolateHelper(valid1,vint8::loadu(&primIDs[i]),vfloat8::loadu(&u[i]),vfloat8::loadu(&v[i]),numUVs,buffer, 
                          P ? P+i : nullptr, 
                          dPdu ? dPdu+i : nullptr, 
                          dPdv ? dPdv+i : nullptr,
                          ddPdudu ? ddPdudu+i : nullptr,
                          ddPdvdv ? ddPdvdv+i : nullptr,
                          ddPdudv ? ddPdudv+i : nullptr,
                          numFloats);
        i+=8;
      }
    }
    AVX_ZERO_UPPER();
  }
Beispiel #23
0
/// \return the next lookahead char, or none if none. Discards timeouts.
static maybe_t<char_event_t> lookahead_pop_evt() {
    while (has_lookahead()) {
        auto evt = lookahead_pop();
        if (! evt.is_timeout()) {
            return evt;
        }
    }
    return none();
}
int Welder::getIndex(const Vector3& vertex) {

    int closestIndex = -1;
    double distanceSquared = inf();

    int ix, iy, iz;
    toGridCoords(vertex, ix, iy, iz);

    // Check against all vertices within radius of this grid cube
    const List& list = grid[ix][iy][iz];

    for (int i = 0; i < list.size(); ++i) {
        double d = (newVertexArray[list[i]] - vertex).squaredMagnitude();

        if (d < distanceSquared) {
            distanceSquared = d;
            closestIndex = list[i];
        }
    }

    if (distanceSquared <= radius * radius) {

        return closestIndex;

    } else {

        // This is a new vertex
        int newIndex = newVertexArray.size();
        newVertexArray.append(vertex);

        // Create a new vertex and store its index in the
        // neighboring grid cells (usually, only 1 neighbor)

        Set<List*> neighbors;

        for (float dx = -1; dx <= +1; ++dx) {
            for (float dy = -1; dy <= +1; ++dy) {
                for (float dz = -1; dz <= +1; ++dz) {
                    int ix, iy, iz;
                    toGridCoords(vertex + Vector3(dx, dy, dz) * radius, ix, iy, iz);
                    neighbors.insert(&(grid[ix][iy][iz]));
                }
            }
        }

        Set<List*>::Iterator neighbor(neighbors.begin());
        Set<List*>::Iterator none(neighbors.end());

        while (neighbor != none) {
            (*neighbor)->append(newIndex);
            ++neighbor;
        }

        return newIndex;
    }
}
Beispiel #25
0
// create subproblem directories for each heuristic algorithm used for
// splitting a problem.
int
createSubProblems()
{
	// separate into axioms and conclusion
	List<Semantic * > axioms;
	List<Semantic * > conclusions;
	ListIterator<Semantic * > ptreesIter(ptrees);
	for ( ; !ptreesIter.done(); ptreesIter++)
	{
		if (!ptreesIter()->getConclusion())
		{
			if (axioms.insertAtEnd(ptreesIter()) != OK)
			{
				ERROR("inserting axioms failed.", errno);
				return(NOTOK);
			}
		}
		else
			break;
	}
	for ( ; !ptreesIter.done(); ptreesIter++)
	{
		if (conclusions.insertAtEnd(ptreesIter()) != OK)
		{
			ERROR("inserting conclusions failed.", errno);
			return(NOTOK);
		}
	}

	// split problems into subproblems
	ListIterator<String> stIter(strategylist);
	for ( ; !stIter.done(); stIter++)
	{
		if ((String("none") == stIter()) && 
		    (none(axioms, conclusions) != OK))
		{
			ERROR("none strategy failed.", errno);
			return(NOTOK);
		}
		else if ((String("bledsoe") == stIter()) && 
			 (bledsoe(axioms, conclusions) != OK))
		{
			ERROR("bledsoe strategy failed.", errno);
			return(NOTOK);
		}
		else if ((String("schaum") == stIter()) && 
			 (schaum(axioms, conclusions) != OK))
		{
			ERROR("schaum strategy failed.", errno);
			return(NOTOK);
		}
	}

	// all done
	return(OK);
}
const QList<CmpSigPinDisplayType>&
CmpSigPinDisplayType::getAllTypes() noexcept {
  static QList<CmpSigPinDisplayType> list{
      none(),
      pinName(),
      componentSignal(),
      netSignal(),
  };
  return list;
}
void add_function(graphics::plot& p, double x0, double x1, Function f, agg::rgba8 color, unsigned flags, int n = 512) {
    agg::rgba8 none(0,0,0,0);
    auto line = new graphics::path();
    line->move_to(x0, f(x0));
    for (int i = 1; i <= n; i++) {
        const double x = x0 + i * (x1 - x0) / n;
        line->line_to(x, f(x));
    }
    p.add(line, color, 1.5, none, flags);
}
Beispiel #28
0
 int totalNQueens(int n) {
     vector<vector<string>> res;
         
     string none(n,'.');
     vector<string> temp(n, none);
     put_one(res, temp, 0, n);
     
     return res.size();
     
 }
Beispiel #29
0
uint24_option
lo_value (uint8_t const universe_bits, uint24_option const value)
{
     if (is_none(value))
          return none();

     uint8_t lo_bits = universe_bits >> 1;
     uint32_t bit_mask = (1 << lo_bits) - 1;

     return some(bit_mask & value);
}
Beispiel #30
0
maybe_t<autoclose_pipes_t> make_autoclose_pipes(const io_chain_t &ios) {
    int pipes[2] = {-1, -1};

    if (pipe(pipes) < 0) {
        debug(1, PIPE_ERROR);
        wperror(L"pipe");
        return none();
    }
    set_cloexec(pipes[0]);
    set_cloexec(pipes[1]);

    if (!pipe_avoid_conflicts_with_io_chain(pipes, ios)) {
        // The pipes are closed on failure here.
        return none();
    }
    autoclose_pipes_t result;
    result.read = autoclose_fd_t(pipes[0]);
    result.write = autoclose_fd_t(pipes[1]);
    return {std::move(result)};
}