void caWaterfallPlot::TimeOut() { // demo curve if(thisUnits != Monitor) { if(!disableDemo) { datamutex->lock(); GausCurv(position); m_data->setData(reducedArray, countRows, ActualNumberOfColumns, getRows(), ActualNumberOfColumns); setCols(ActualNumberOfColumns); if(firstDemoPlot) { updatePlot(); m_data->setLimits(0., getCols(), 0., getRows(), thisIntensityMin, thisIntensityMax); firstDemoPlot = false; } datamutex->unlock(); if(drift > 0 && position >= NumberOfColumns) drift = -1; if(drift < 0 && position <= 0) drift = 1; position += drift; } else { if(reducedArray != (double*) 0) { datamutex->lock(); m_data->setData(reducedArray, countRows, ActualNumberOfColumns, getRows(), ActualNumberOfColumns); if(firstTimerPlot) { updatePlot(); m_data->setLimits(0., getCols(), 0., getRows(), thisIntensityMin, thisIntensityMax); firstTimerPlot = false; } datamutex->unlock(); } } myReplot(); } }
//create the cells for the maze void Maze::createMaze() { stack<Cell*> cells; cells.push(getCell(rand()%getRows(), rand()%getCols())); while (!cells.empty()) { Cell* c1; c1 = cells.top(); cells.pop(); c1->setVisited(); vector<direction> neighbors; getUnvisitedNeighbors(c1, neighbors); if (!neighbors.empty()) { cells.push(c1); int i = rand()%neighbors.size(); connect(c1, neighbors.at(i)); cells.push(getCell(c1->getRow() + Direction::row(neighbors.at(i)), c1->getCol() + Direction::col(neighbors.at(i)))); } } setStartCell(getCell(0, rand() % getCols())); setEndCell(getCell(getRows()-1, rand() % getCols())); startCell = getStartCell(); endCell = getEndCell(); }
void caWaterfallPlot::updatePlot() { // A color bar on the right axis /* QwtScaleWidget *rightAxis = plot->axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Wavelength()); plot->setAxisScale(QwtPlot::yRight, thisIntensityMin, thisIntensityMax); plot->enableAxis(QwtPlot::yRight); thisColormap = spectrum_wavelength; */ // disable labels of left axis plot->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtAbstractScaleDraw::Labels, false); plot->setAxisFont(QwtPlot::xBottom, QFont("Arial", 10)); plot->setAxisFont(QwtPlot::yLeft, QFont("Arial", 10)); plot->plotLayout()->setAlignCanvasToScales(true); plot->setAxisScale(QwtPlot::xTop, 0, getCols()); plot->setAxisScale(QwtPlot::xBottom, 0, getCols()); plot->setAxisMaxMinor(QwtPlot::xTop, 0); plot->setAxisScale(QwtPlot::yLeft, getRows(), 0.0); plot->setAxisMaxMinor(QwtPlot::yLeft, 0); plot->replot(); }
bool multiArrayMessageMapToMatrixEigen(MultiArrayMessageType_& m, EigenType_& e) { if (e.IsRowMajor != isRowMajor(m)) { ROS_ERROR("multiArrayMessageToMatrixEigen() failed because the storage order is not compatible."); return false; } e.resize(getRows(m), getCols(m)); e = Eigen::Map<EigenType_>(m.data.data(), getRows(m), getCols(m)); return true; }
__host__ void gridTransform_(const SrcPtr& src, GpuMat_<DstType>& dst, const UnOp& op, const MaskPtr& mask, Stream& stream = Stream::Null()) { const int rows = getRows(src); const int cols = getCols(src); CV_Assert( getRows(mask) == rows && getCols(mask) == cols ); dst.create(rows, cols); grid_transform_detail::transform<Policy>(shrinkPtr(src), shrinkPtr(dst), op, shrinkPtr(mask), rows, cols, StreamAccessor::getStream(stream)); }
__host__ void gridTransform_(const SrcPtr1& src1, const SrcPtr2& src2, GpuMat_<DstType>& dst, const BinOp& op, Stream& stream = Stream::Null()) { const int rows = getRows(src1); const int cols = getCols(src1); CV_Assert( getRows(src2) == rows && getCols(src2) == cols ); dst.create(rows, cols); grid_transform_detail::transform<Policy>(shrinkPtr(src1), shrinkPtr(src2), shrinkPtr(dst), op, WithOutMask(), rows, cols, StreamAccessor::getStream(stream)); }
bool multiArrayMessageCopyToMatrixEigen(const MultiArrayMessageType_& m, EigenType_& e) { if (e.IsRowMajor != isRowMajor(m)) { ROS_ERROR("multiArrayMessageToMatrixEigen() failed because the storage order is not compatible."); return false; } EigenType_ tempE(getRows(m), getCols(m)); tempE = Eigen::Map<const EigenType_>(m.data.data(), getRows(m), getCols(m)); e = tempE; return true; }
/*! Operator that allows to substract two row vectors that have the same size. \exception vpException::dimensionError If the size of the two vectors differ. */ vpRowVector & vpRowVector::operator-=(vpRowVector v) { if (getCols() != v.getCols() ) { throw(vpException(vpException::dimensionError, "Cannot substract (1x%d) row vector to (1x%d) row vector", getCols(), v.getCols())) ; } for (unsigned int i=0;i<colNum;i++) (*this)[i] -= v[i]; return (*this); }
/*! Operator that allows to add to row vectors that have the same size. \exception vpException::dimensionError If the vectors size differ. */ vpRowVector vpRowVector::operator+(const vpRowVector &v) const { if (getCols() != v.getCols() ) { throw(vpException(vpException::dimensionError, "Cannot add (1x%d) row vector to (1x%d) row vector", getCols(), v.getCols())) ; } vpRowVector r(colNum) ; for (unsigned int i=0;i<colNum;i++) r[i] = (*this)[i] + v[i]; return r; }
/*! Operator that allows to substract to row vectors that have the same size. \exception vpException::dimensionError If the vectors size differ. */ vpRowVector vpRowVector::operator-(const vpRowVector &m) const { if (getCols() != m.getCols() ) { throw(vpException(vpException::dimensionError, "Cannot substract (1x%d) row vector to (1x%d) row vector", getCols(), m.getCols())) ; } vpRowVector v(colNum) ; for (unsigned int i=0;i<colNum;i++) v[i] = (*this)[i] - m[i]; return v; }
__host__ ZipPtrSz< tuple<typename PtrTraits<Ptr0>::ptr_type, typename PtrTraits<Ptr1>::ptr_type> > zipPtr(const Ptr0& ptr0, const Ptr1& ptr1) { const int rows = getRows(ptr0); const int cols = getCols(ptr0); CV_Assert( getRows(ptr1) == rows && getCols(ptr1) == cols ); ZipPtrSz< tuple<typename PtrTraits<Ptr0>::ptr_type, typename PtrTraits<Ptr1>::ptr_type> > z(make_tuple(shrinkPtr(ptr0), shrinkPtr(ptr1))); z.rows = rows; z.cols = cols; return z; }
__host__ RemapPtr2Sz<typename PtrTraits<SrcPtr>::ptr_type, typename PtrTraits<MapXPtr>::ptr_type, typename PtrTraits<MapYPtr>::ptr_type> remapPtr(const SrcPtr& src, const MapXPtr& mapx, const MapYPtr& mapy) { const int rows = getRows(mapx); const int cols = getCols(mapx); CV_Assert( getRows(mapy) == rows && getCols(mapy) == cols ); RemapPtr2Sz<typename PtrTraits<SrcPtr>::ptr_type, typename PtrTraits<MapXPtr>::ptr_type, typename PtrTraits<MapYPtr>::ptr_type> r; r.src = shrinkPtr(src); r.mapx = shrinkPtr(mapx); r.mapy = shrinkPtr(mapy); r.rows = rows; r.cols = cols; return r; }
__host__ void gridFindMaxVal_(const SrcPtr& src, GpuMat_<ResType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null()) { dst.create(1, 1); dst.setTo(Scalar::all(-std::numeric_limits<ResType>::max()), stream); const int rows = getRows(src); const int cols = getCols(src); CV_Assert( getRows(mask) == rows && getCols(mask) == cols ); grid_reduce_detail::maxVal<Policy>(shrinkPtr(src), dst[0], shrinkPtr(mask), rows, cols, StreamAccessor::getStream(stream)); }
// << inserts character c at the current cursor position // BConsole& BConsole::putChar(char c) { if(curRow>=0 && curCol >=0 && curRow < getRows() && curCol < getCols() ){ // prints the character only if it is on screen ::putch(c); setBufChar(c); } return *this; }
bool String::operator==(const InternalType& it) { if (const_cast<InternalType&>(it).isString() == false) { return false; } String* pS = const_cast<InternalType&>(it).getAs<types::String>(); if (pS->getRows() != getRows() || pS->getCols() != getCols()) { return false; } wchar_t **p1 = get(); wchar_t **p2 = pS->get(); for (int i = 0 ; i < getSize() ; i++) { if (wcscmp(p1[i], p2[i]) != 0) { return false; } } return true; }
__host__ BinaryTransformPtrSz<typename PtrTraits<Src1Ptr>::ptr_type, typename PtrTraits<Src2Ptr>::ptr_type, Op> transformPtr(const Src1Ptr& src1, const Src2Ptr& src2, const Op& op) { const int rows = getRows(src1); const int cols = getCols(src1); CV_Assert( getRows(src2) == rows && getCols(src2) == cols ); BinaryTransformPtrSz<typename PtrTraits<Src1Ptr>::ptr_type, typename PtrTraits<Src2Ptr>::ptr_type, Op> ptr; ptr.src1 = shrinkPtr(src1); ptr.src2 = shrinkPtr(src2); ptr.op = op; ptr.rows = rows; ptr.cols = cols; return ptr; }
/* * Method used to test a maze to make sure all cells * have been visited. * */ bool Maze::allCellsVisited() const { for (int r=0; r < getRows(); r++) { for (int c=0; c < getCols(); c++) { if (!getCell(r,c)->isVisited()) return false; } } return true; }
bool Cell::isEmpty() { if (getDims() == 2 && getRows() == 0 && getCols() == 0) { return true; } return false; }
Cell* Cell::set(int _iRows, int _iCols, const InternalType* _pIT) { if (_iRows < getRows() && _iCols < getCols()) { return set(_iCols * getRows() + _iRows, _pIT); } return NULL; }
__host__ BrdBase<BrdWrap, typename PtrTraits<SrcPtr>::ptr_type> brdWrap(const SrcPtr& src) { BrdBase<BrdWrap, typename PtrTraits<SrcPtr>::ptr_type> b; b.src = shrinkPtr(src); b.rows = getRows(src); b.cols = getCols(src); return b; }
__host__ DerivXPtrSz<typename PtrTraits<SrcPtr>::ptr_type> derivXPtr(const SrcPtr& src) { DerivXPtrSz<typename PtrTraits<SrcPtr>::ptr_type> s; s.src = shrinkPtr(src); s.rows = getRows(src); s.cols = getCols(src); return s; }
__host__ LaplacianPtrSz<ksize, typename PtrTraits<SrcPtr>::ptr_type> laplacianPtr(const SrcPtr& src) { LaplacianPtrSz<ksize, typename PtrTraits<SrcPtr>::ptr_type> ptr; ptr.src = shrinkPtr(src); ptr.rows = getRows(src); ptr.cols = getCols(src); return ptr; }
__host__ void gridPyrUp(const SrcPtr& src, GpuMat_<DstType>& dst, Stream& stream = Stream::Null()) { const int rows = getRows(src); const int cols = getCols(src); dst.create(rows * 2, cols * 2); pyramids_detail::pyrUp(shrinkPtr(src), shrinkPtr(dst), rows, cols, dst.rows, dst.cols, StreamAccessor::getStream(stream)); }
__host__ BrdConstant<typename PtrTraits<SrcPtr>::ptr_type> brdConstant(const SrcPtr& src, typename PtrTraits<SrcPtr>::value_type val) { BrdConstant<typename PtrTraits<SrcPtr>::ptr_type> b; b.src = shrinkPtr(src); b.rows = getRows(src); b.cols = getCols(src); b.val = val; return b; }
__host__ void gridHistogram_(const SrcPtr& src, GpuMat_<ResType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null()) { CV_Assert( deviceSupports(SHARED_ATOMICS) ); const int rows = getRows(src); const int cols = getCols(src); CV_Assert( getRows(mask) == rows && getCols(mask) == cols ); dst.create(1, BIN_COUNT); dst.setTo(0, stream); grid_histogram_detail::histogram<BIN_COUNT, Policy>(shrinkPtr(src), dst[0], shrinkPtr(mask), rows, cols, StreamAccessor::getStream(stream)); }
// // Recursively generate mangled names. // TString TType::buildMangledName() const { TString mangledName; if (isMatrix()) mangledName += 'm'; else if (isVector()) mangledName += 'v'; switch (type) { case EbtFloat: mangledName += 'f'; break; case EbtInt: mangledName += 'i'; break; case EbtUInt: mangledName += 'u'; break; case EbtBool: mangledName += 'b'; break; case EbtSampler2D: mangledName += "s2"; break; case EbtSampler3D: mangledName += "s3"; break; case EbtSamplerCube: mangledName += "sC"; break; case EbtSampler2DArray: mangledName += "s2a"; break; case EbtSamplerExternalOES: mangledName += "sext"; break; case EbtSampler2DRect: mangledName += "s2r"; break; case EbtISampler2D: mangledName += "is2"; break; case EbtISampler3D: mangledName += "is3"; break; case EbtISamplerCube: mangledName += "isC"; break; case EbtISampler2DArray: mangledName += "is2a"; break; case EbtUSampler2D: mangledName += "us2"; break; case EbtUSampler3D: mangledName += "us3"; break; case EbtUSamplerCube: mangledName += "usC"; break; case EbtUSampler2DArray: mangledName += "us2a"; break; case EbtSampler2DShadow: mangledName += "s2s"; break; case EbtSamplerCubeShadow: mangledName += "sCs"; break; case EbtSampler2DArrayShadow: mangledName += "s2as"; break; case EbtStruct: mangledName += structure->mangledName(); break; case EbtInterfaceBlock: mangledName += interfaceBlock->mangledName(); break; default: UNREACHABLE(); } if (isMatrix()) { mangledName += static_cast<char>('0' + getCols()); mangledName += static_cast<char>('x'); mangledName += static_cast<char>('0' + getRows()); } else { mangledName += static_cast<char>('0' + getNominalSize()); } if (isArray()) { char buf[20]; snprintf(buf, sizeof(buf), "%d", arraySize); mangledName += '['; mangledName += buf; mangledName += ']'; } return mangledName; }
__host__ void gridMinMaxLoc_(const SrcPtr& src, GpuMat_<ResType>& valBuf, GpuMat_<int>& locBuf, const MaskPtr& mask, Stream& stream = Stream::Null()) { const int rows = getRows(src); const int cols = getCols(src); CV_Assert( getRows(mask) == rows && getCols(mask) == cols ); dim3 grid, block; grid_minmaxloc_detail::getLaunchCfg<Policy>(rows, cols, block, grid); valBuf.create(2, grid.x * grid.y); locBuf.create(2, grid.x * grid.y); grid_minmaxloc_detail::minMaxLoc<Policy>(shrinkPtr(src), valBuf[0], valBuf[1], locBuf[0], locBuf[1], shrinkPtr(mask), rows, cols, StreamAccessor::getStream(stream)); }
double RMatrix::getUniformScaleFactor() const { if (getRows()!=2 || getCols()!=2) { return RNANDOUBLE; } double a = getRotationAngle(); if (RMath::isNaN(a)) { return RNANDOUBLE; } return get(0,0) / cos(a); }
RVector RMatrix::multiplyWith(const RVector& v) const { if (getRows()==2 && getCols()==2) { return RVector( get(0,0)*v.x + get(0,1)*v.y, get(1,0)*v.x + get(1,1)*v.y ); } return RVector::invalid; }
__host__ void gridTransform_(const SrcPtr& src, const tuple< GpuMat_<D0>&, GpuMat_<D1>& >& dst, const OpTuple& op, const MaskPtr& mask, Stream& stream = Stream::Null()) { CV_StaticAssert( tuple_size<OpTuple>::value == 2, "" ); const int rows = getRows(src); const int cols = getCols(src); CV_Assert( getRows(mask) == rows && getCols(mask) == cols ); get<0>(dst).create(rows, cols); get<1>(dst).create(rows, cols); grid_transform_detail::transform_tuple<Policy>(shrinkPtr(src), shrinkPtr(zipPtr(get<0>(dst), get<1>(dst))), op, shrinkPtr(mask), rows, cols, StreamAccessor::getStream(stream)); }