double SumOfRow(matrix mtx, int row){
	
	
	if(!mtx){
		return -1;
	}
	//printf("SumOfRow\n");
	int totalRows = getRows(mtx);
	if( row<1 || row>totalRows){
		return -1;
	}
	
	int currentRow = 0;
	int rowtemp;
	int j;
	double val=0;
	matrix mtxtemp = mtx;
	while(mtxtemp!=NULL){
		if(row<(currentRow+mtxtemp->rows)){
			rowtemp = row-currentRow;
			for(j=1;j<=mtxtemp->cols;j++){
				val+=ELEM(mtxtemp,rowtemp,j);
			}
		}else{
			currentRow+=mtxtemp->rows;
		}
		mtxtemp=mtxtemp->Extra;
	}
	return val;
}
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();
}
double getE(const_matrix mtx, int row, int col) {
	if(!mtx){
		printf("ERROR matrix NULL!\n");
		return -1;
	}
	//printf("getE\n");
	int rowtemp;
	int totalRows = getRows(mtx);
	int totalCols = mtx->cols;
	if(row <= 0 || row > totalRows ||
			col <= 0 || col > totalCols){
		return -2;
	}
	
	int currentRow = 0;
	matrix mtxtemp = mtx;
	matrix mtxprev = mtx;
	while(row>(currentRow+mtxtemp->rows)){
		currentRow+=mtxtemp->rows;
		mtxprev = mtxtemp;
		mtxtemp = mtxtemp->Extra;

		if(mtxtemp==NULL){
			printf("ERROR exceeded size of matrix without finding the correct row!\n");
			return -1;
		}
	}
	
	rowtemp = row-currentRow;

	return (double) ELEM(mtxprev,rowtemp,col);
}
Exemple #4
0
__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;
}
Exemple #5
0
int MRO_IsSquareMatrix::operator()() const
{
	if(getRows() == getColumns())
		return 1; // Matrix is square

	return 0; //  Matrix is NOT square
}
Exemple #6
0
int MRO_SizeEqual::operator()(const MatrixAliasConstant& operand) const
{
	if(operand.getRows() == getRows() && operand.getColumns() == getColumns())
		return 1; // Size is equal

	return 0; // Size is NOT equal
}
Exemple #7
0
int MRO_IsRowVector::operator()() const
{
	if(getRows() == 1)
		return 1; // Matrix is row vector

	return 0; //  Matrix is NOT row vector
}
Exemple #8
0
Matrix MRO_Negative::operator()() const
{
	Matrix result(getRows(), getColumns());

	unsigned int i, j;

	for (i = 0; i < getRows(); i++) {

		for (j = 0; j < getColumns(); j++) {

			result.element(i, j) = -1 * element(i, j);
		}
	}

	return result;
}
Exemple #9
0
 // << 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;
 }
int printMatrixLL(matrix_linklist LL){
  
  #ifdef _ERROR_CHECKING_ON_
  if(LL==NULL){
    #ifdef _ERROR_
    fprintf(stderr,"ERROR LL is NULL in printMatrixLL\n");
    #endif
    #ifdef _FORCE_HARD_CRASH_
    exit(1);
    #endif
    return -1;
  }
  #endif

  int rows;
  int i;
	printf("\nLength %d\n",LL->length);
	LL_MNode node = LL->start;
  int count;
  count = 1;
	while(node!=NULL){
    rows = getRows(node->data);
		printf("Sequence %d \t Rows of Data %d\n",count,rows);
    for(i=1;i<=rows;i++){
      printf("Row %d %g\n",i,getE(node->data,i,1));
    }
		node=node->next;
    count++;
	}
  printf("Finished with printMatrixLL\n");

	return 0;
}
Exemple #11
0
__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;
}
Exemple #12
0
__host__ ZipPtrSz< tuple<typename PtrTraits<Ptr0>::ptr_type, typename PtrTraits<Ptr1>::ptr_type, typename PtrTraits<Ptr2>::ptr_type> >
zipPtr(const Ptr0& ptr0, const Ptr1& ptr1, const Ptr2& ptr2)
{
    const int rows = getRows(ptr0);
    const int cols = getCols(ptr0);

    CV_Assert( getRows(ptr1) == rows && getCols(ptr1) == cols );
    CV_Assert( getRows(ptr2) == rows && getCols(ptr2) == cols );

    ZipPtrSz< tuple<typename PtrTraits<Ptr0>::ptr_type, typename PtrTraits<Ptr1>::ptr_type, typename PtrTraits<Ptr2>::ptr_type> >
            z(make_tuple(shrinkPtr(ptr0), shrinkPtr(ptr1), shrinkPtr(ptr2)));
    z.rows = rows;
    z.cols = cols;

    return z;
}
Exemple #13
0
void GlobalViewList::event( ViewEvent ve, View * view )
//-----------------------------------------------------
{
    if( ve == VEClose || ve == VECreate ) {
        if( view->identity() == VIDetailView ) {
            int             i;
            int             maxRows = getRows() + _topIndex;
            DetailView *    dtv = (DetailView *) view;
            drmem_hdl       drhdl = dtv->symHandle();

            for( i = _topIndex; i < maxRows; i += 1 ) {
                Symbol * sym = getSymbol( i );

                if( sym == NULL ) {
                    break;
                }
                if( drhdl == sym->getHandle() ) {
                    invalidateRow( i - _topIndex );
                    break;
                }
            }
        }
    } else {
        switch( ve ) {
        case VEBrowseFileChange:
        case VEQueryFiltChange:
            reLoad();
            break;
        }
    }
}
int getMatrixLLLastMatchAtRow(matrix_linklist LL, double match, int R){
  
  if(LL==NULL){
    fprintf(stderr,"ERROR LL is NULL in getMatrixLLLastMatch\n");
    return -1;
  }
  LL_MNode node = LL->start;
  int rows;
  int seq = 0;
  int lastseq = -1;
  while(node!=NULL){
    seq++;
    rows = getRows(node->data);
    
    if(R>rows){
      fprintf(stderr,"ERROR getMatrixLLLastMatch data data only\n");
      fprintf(stderr," has %d rows but you have requested\n",rows);
      fprintf(stderr," a match with row %d.\n",R);
      return -1;
    }

    if(getE(node->data,R,1)==match){
      lastseq = seq;
    }
    node=node->next;
  }
    
  return lastseq;
}
int getMatrixLLNumberElemGreaterThanMatchAtRow(matrix_linklist LL, double match, int R){

  if(LL==NULL){
    fprintf(stderr,"ERROR LL is NULL in getMatrixLLNumberElemGreaterThanMatchAtRow\n");
  }
  
  int rows;
  LL_MNode node = LL->start;
  int count = 0;
  while(node!=NULL){

    rows = getRows(node->data);
    
    if(R>rows){
      fprintf(stderr,"ERROR getMatrixLLNumberMatchAtRow data data only\n");
      fprintf(stderr," has %d rows but you have requested\n",rows);
      fprintf(stderr," a match with row %d.\n",R);
      return -1;
    }
    
    if(getE(node->data,R,1)>match){
      count++;
    }
    node=node->next;
  }
    
  return count;
}
Exemple #16
0
Matrix MRO_Subtract::operator()(const MatrixAliasConstant& operand) const
{
	Matrix result(getRows(), getColumns());
	unsigned int i;

	if (operand.getRows() != getRows() || operand.getColumns() != getColumns()) {
		error("MRO_Subtract : Dimensions are not consistent\n");
		return result; // Return empty matrix
	}

	for (i = 0; i < getRows()*getColumns(); i++) {
		result.element(i) = element(i) - operand.element(i);
	}

	return result;
}
Exemple #17
0
bool Outline::paint()
//-------------------
{
    OutlineElement * elm;
    int              maxRows = getRows();
    int              index = -1 * _topIndex;
    WPoint           hotSize;
    WPoint           avg;
    WPoint           max;

    textMetrics( avg, max );

    if( count() ) {
        GlobalHotSpots->hotSpotSize( OutlineLeafUp, hotSize );  // rely on all being same size

        for( elm = element( 0 ); elm != NULL; elm = elm->visibleSib() ) {
            elm->drawLine( this, index, hotSize.x(), max.y() );

            if( index >= maxRows ) {
                break;
            }
        }

        return HotWindowList::paint();
    } else {
        ScreenDev dev;

        dev.open( this );
        dev.drawText( WPoint( 0, 0 ), emptyText() );
        dev.close();

        return true;
    }
}
Exemple #18
0
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;
}
int printMatrix(const_matrix mtx) {
	if (!mtx){
		printf("Matrix does not appear to exist!\n");
		return -1;
	}
	int i;
	int j;

	int totalRows = getRows(mtx);
	int totalCols = mtx->cols;

	matrix mtxtemp;

	printf("Rows %d Columns %d\n",totalRows, totalCols);

	mtxtemp = mtx;
	while(mtxtemp!=NULL){
		for (i=1;i<=mtxtemp->rows;i++) {
			for(j=1;j<=mtxtemp->cols;j++){
				printf("%.6g \t",getE(mtxtemp,i,j));			
			}
			printf("\n");
		}
		mtxtemp=mtxtemp->Extra;
	}
	return 0;
}
Exemple #20
0
__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;
}
Exemple #21
0
bool Cell::isEmpty()
{
    if (getDims() == 2 && getRows() == 0 && getCols() == 0)
    {
        return true;
    }
    return false;
}
Exemple #22
0
void MWO_Randomise::operator()() const
{
	unsigned int i;

	for (i = 0; i < getRows()*getColumns(); i++) {
		element(i) = _rand();
	}
}
Exemple #23
0
void MWO_Set::operator()() const
{
	unsigned int i;

	for (i = 0; i < getRows()*getColumns(); i++) {
		element(i) = 1;
	}
}
Exemple #24
0
void MWO_Set::operator()(const double val) const
{
	unsigned int i;

	for (i = 0; i < getRows()*getColumns(); i++) {
		element(i) = val;
	}
}
Exemple #25
0
__host__ void gridFindMinMaxVal_(const SrcPtr& src, GpuMat_<ResType>& dst, const MaskPtr& mask, Stream& stream = Stream::Null())
{
    dst.create(1, 2);
    dst.col(0).setTo(Scalar::all(std::numeric_limits<ResType>::max()), stream);
    dst.col(1).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::minMaxVal<Policy>(shrinkPtr(src),
                                          dst[0],
                                          shrinkPtr(mask),
                                          rows, cols,
                                          StreamAccessor::getStream(stream));
}
Exemple #26
0
/*
 *  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;
}
Exemple #27
0
__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__ 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;
}
/*!\brief Generates the table of heuristic values for use in
 * the tour algorithm.
 */
void GameBoard::GameBoardInternal::generateHeuristicTable()
{
	for (unsigned i = 0; i < getRows(); ++i)
	{
		for (unsigned j = 0; j < getColumns(); ++j)
		{
			(*this)(i, j).setHeuristicValue(2);

			if (i > 0 && i < getRows() - 1)
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+1);
			if (j > 0 && j < getColumns() - 1)
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+1);
			
			if (i > 1 && j > 1 && i < getRows() - 2 && j < getColumns() - 2)
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+2);
			if (i > 1 && i < getRows() - 2)
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+1);
			if (j > 1 && j < getColumns() - 2)
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+1);
			if (i > 1  && i < getRows() - 2 && j <= getColumns() - 2 && (j == 1 || j == getColumns() - 2))
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+1);
			if (j > 1 && j < getColumns() - 2 && i <= getRows() - 2 && (i == 1 || i == getRows() - 2))
				(*this)(i,j).setHeuristicValue((*this)(i,j).getHeuristicValue()+1);
		}
	}
}
void tmatrix<nr_type_t>::transpose (void) {
  nr_type_t v;
  for (int r = 0; r < getRows (); r++)
    for (int c = 0; c < r; c++) {
      v = get (r, c);
      set (r, c, get (c, r));
      set (c, r, v);
    }
}