当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix::GetCols方法代码示例

本文整理汇总了C++中Matrix::GetCols方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::GetCols方法的具体用法?C++ Matrix::GetCols怎么用?C++ Matrix::GetCols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix的用法示例。


在下文中一共展示了Matrix::GetCols方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Diag

/**
 * returns a diagonal matrix
 * @param  v a vector
 * @return a diagonal matrix with the given vector v on the diagonal
 */
Matrix Diag(const Matrix& v)
{
  Matrix res;
  if (v.GetCols() == 1)
  {
    // the given matrix is a vector n x 1
    int rows = v.GetRows();
    res = Matrix(rows, rows);

    // copy the values of the vector to the matrix
    for (int r=1; r <= rows; r++)
    {
      res(r, r) = v.get(r, 1);
    }
  }
  else if (v.GetRows() == 1)
  {
    // the given matrix is a vector 1 x n
    int cols = v.GetCols();
    res = Matrix(cols, cols);

    // copy the values of the vector to the matrix
    for (int c=1; c <= cols; c++)
    {
      res(c, c) = v.get(1, c);
    }
  }
  else
  {
    throw Exception("Parameter for diag must be a vector");
  }
  return res;
}
开发者ID:cnjoroge,项目名称:slam,代码行数:38,代码来源:matrix.cpp

示例2: mean

// / Calculates the mean value of the elements in a matrix.
double mean(Matrix < double >&m)
{
    double sum = 0.;

    for (int r = 0; r < m.GetRows(); r++)
        for (int c = 0; c < m.GetCols(); c++)
            sum += m[r][c];
    return sum / double (m.GetRows() * m.GetCols());
}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:10,代码来源:Matrix.cpp

示例3: scalprod

Complex scalprod(Matrix < Complex > &m1, Matrix < double >&m2)
{
    assert((m1.GetRows() == m2.GetRows()) && (m1.GetCols() == m2.GetCols()));
    Complex sum(0, 0);

    for (int r = 0; r < m1.GetRows(); r++)
        for (int c = 0; c < m1.GetCols(); c++)
            sum += m1[r][c] * m2[r][c];
    return sum;
}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:10,代码来源:Matrix.cpp

示例4: variance

// / Calculates the varaince of the elements in a matrix.
double variance(Matrix < double >&m)
{
    double sum = 0.;

    double average = mean(m);

    for (int r = 0; r < m.GetRows(); r++)
        for (int c = 0; c < m.GetCols(); c++)
            sum += (m[r][c] - average) * (m[r][c] - average);
    return sum / double (m.GetRows() * m.GetCols() - 1);
}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:12,代码来源:Matrix.cpp

示例5: scalconj

Complex scalconj(Matrix < Complex > &m1, Matrix < Complex > &m2)        // total(A.B*)
{
    assert((m1.GetRows() == m2.GetRows()) && (m1.GetCols() == m2.GetCols()));
    Complex sum(0, 0);

    for (int r = 0; r < m1.GetRows(); r++)
        for (int c = 0; c < m1.GetCols(); c++)
            sum += m1[r][c] * conj(m2[r][c]);
    return sum;

}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:11,代码来源:Matrix.cpp

示例6: fft2

Matrix fft2(Matrix &m, int isign)
{
    assert(m.bComplex == TRUE);
    int ndim = 2;	
    long row = m.GetRows(); 
    long col = m.GetCols();
	
    Matrix ret(m);
    unsigned long nn[3];
		
    nn[1] = row;
    nn[2] = col / 2;
		
#if 1
    float *pdata = new float[row * col + 1];
    memcpy( pdata + 1, m.p, sizeof(float) * row * col);
    fourn( pdata, nn, ndim, isign );
    memcpy( ret.p, pdata + 1, sizeof(float) * row * col);
    delete[] pdata;
#else
	float* pdata = new float[row * col];
	memcpy(pdata, m.p, sizeof(float) * row * col);
	CUFFT::fft(pdata, col / 2, row, isign == 1);
	CUFFT::fft(pdata, col / 2, row, isign != 1);
	memcpy(ret.p, pdata, sizeof(float) * row * col);
	delete [] pdata;
#endif
    ret.bComplex = TRUE;
		
    return ret;	
}
开发者ID:tibo-xx,项目名称:UNR_Gabor,代码行数:31,代码来源:Matrix.cpp

示例7: WhitenFrame

Matrix WhitenFrame(Matrix &m)
{
    int nRow = m.GetRows();
    int nCol = m.GetCols();
    assert(nRow == nCol);
	
    Matrix fx(nRow), fy(nRow);
    Meshgrid(fx, -nRow / 2, nRow / 2 - 1, fy, -nRow / 2, nRow / 2 - 1);
    Matrix theta = fx;
    Matrix rho = fx;
    
    cart2pol( fx,fy,theta,rho );
	
#if 1
    Matrix complex = Complex(m);
    Matrix fftm = fft2(complex, 1);
    Matrix imF = fftshift(fftm);
    Matrix time = times(rho, imF);
    Matrix imW = fftshift(time);
#else
    Matrix complex = Complex(m);
    Matrix fftm = fft2(complex, 1);
    Matrix imF = fftshift(fftm);
    Matrix time = times(rho, imF);
    Matrix imW = fftshift(time);
#endif

    return imW;
}
开发者ID:tibo-xx,项目名称:UNR_Gabor,代码行数:29,代码来源:Matrix.cpp

示例8: ZeroUnPad

void ZeroUnPad(Matrix < Complex > &unpadded, Matrix < Complex > &padded)        // for 
                                                                                // square 
                                                                                // matrices
{
    // remove zero padding
    int unpadded_size = unpadded.GetCols();

    int padded_size = padded.GetCols();

    int low = (padded_size - unpadded_size) / 2;

    int high = (padded_size + unpadded_size) / 2;

    for (int ii = low; ii < high; ii++)
        for (int jj = low; jj < high; jj++)
            unpadded[ii - high][jj - high] = padded[ii][jj];
}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:17,代码来源:Matrix.cpp

示例9: total

Complex total(Matrix < Complex > &m)
{
    Complex sum(0, 0);

    for (int r = 0; r < m.GetRows(); r++)
        for (int c = 0; c < m.GetCols(); c++)
            sum += m[r][c];
    return sum;
}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:9,代码来源:Matrix.cpp

示例10: ZeroPad

void ZeroPad(Matrix < Complex > &unpadded, Matrix < Complex > &padded)  // for 
                                                                        // square 
                                                                        // matrices
{
    // Pad a matrix to padding x padding
    int unpadded_size = unpadded.GetCols();

    int padded_size = padded.GetCols();

    int low = (padded_size - unpadded_size) / 2;

    int high = (padded_size + unpadded_size) / 2;

    for (int ii = low; ii < high; ii++)
        for (int jj = low; jj < high; jj++)
            padded[ii][jj] = unpadded[ii - low][jj - low];

}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:18,代码来源:Matrix.cpp

示例11: norm2

double norm2(Matrix < Complex > &m)
{
    double sum = 0.;

    for (int r = 0; r < m.GetRows(); r++)
        for (int c = 0; c < m.GetCols(); c++)
            sum += norm(m[r][c]);
    return sum;

}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:10,代码来源:Matrix.cpp

示例12: ExtractCode

	int ExtractCode( Image < uint8 > & DATANOR, Code < float > & codedata, Matrix < float > & Feat,
		 struct osiris_parameter & param, Filtres < float > & Gabor, Appoints & points )
		 {

		   Feat = Featextract( DATANOR, Gabor, points );
		   codedata.SetSize( Feat.GetRows(), Feat.GetCols() );
		   codedata.TMPLATE = TMextract( Feat );
		   codedata.MASK.init( 1 );

		   return ( 0 );
	}
开发者ID:ddcien,项目名称:Iris-extraction,代码行数:11,代码来源:osiris.cpp

示例13: ShowMatrix

void ShowMatrix(ostream& os, const Matrix<T>& m)
{
  const size_t MaxR = m.GetRows();
  const size_t MaxC = m.GetCols();
  size_t r, c;

  for (r = 0; r < MaxR; ++r)
  {
    os << "[ ";

    for (c = 0; c < MaxC; ++c)
      os << setw(3) << m.Get(r,c) << " ";

    os << "]\r\n";
  }
}
开发者ID:heavilessrose,项目名称:my-sync,代码行数:16,代码来源:testmatr.cpp

示例14: toBoolean

bool IfFilterFactory::toBoolean(const Value& value)
{
	bool result = false;

	wchar_t type = value.GetType();
	switch (type)
	{
	case 'i':
		{
			int i = value.GetInteger();
			result = (i != 0);
		}
		break;
	case 'f':
		{
			double f = value.GetFloat();
			result = (f != 0.0 && f == f);
		}
		break;
	case 'b':
		{
			result = value.GetBool();
		}
		break;
	case 's':
		{
			wstring s = value.GetString();
			result = s.length() > 0 && s != L"false" && s != L"0";
		}
		break;
	case 'm':
		{
			Matrix<Value> m = value.GetArray();
			result = m.GetRows() > 0 && m.GetCols() > 0;
		}
		break;
	default:
		result = false;
		break;
	}

	return result;
}
开发者ID:Noiled,项目名称:equalizerapo,代码行数:43,代码来源:IfFilterFactory.cpp

示例15: mat2fits

// / Converts a matrix composed of doubles into a FITS file
void mat2fits(Matrix < double >&m, const char *filename)
{
    int status = 0;

    fitsfile *fptr;

    long fpixel = 1, naxis = 2, nelements;

    long naxes[2];

    // Initialise storage
    naxes[0] = (long)m.GetRows();
    naxes[1] = (long)m.GetCols();
    nelements = naxes[0] * naxes[1];

    double *ptrimg;

    // Create pointer image
    ptrimg = (double *)malloc(nelements * sizeof(double));

    for (int ii = 0; ii < naxes[0]; ii++)
        for (int jj = 0; jj < naxes[1]; jj++)
            ptrimg[ ii + jj * naxes[0] ] = m[ii][jj];

    // Create new file, write image, then close file
    if (status == 0)
        fits_create_file(&fptr, filename, &status);
    if (status == 0)
        fits_create_img(fptr, DOUBLE_IMG, naxis, naxes, &status);
    if (status == 0)
        fits_write_img(fptr, TDOUBLE, fpixel, nelements, &ptrimg[0], &status);
    if (status == 0)
        fits_close_file(fptr, &status);
    free(ptrimg);

    fits_report_error(stderr, status);

}
开发者ID:bkloppenborg,项目名称:oifits-sim,代码行数:39,代码来源:Matrix.cpp


注:本文中的Matrix::GetCols方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。