コード例 #1
0
ファイル: ops_select.cpp プロジェクト: cfrahnow/hyrise
  std::shared_ptr<AbstractTable> createRawTable() {
    metadata_vec_t cols({ *ColumnMetadata::metadataFromString("INTEGER", "col1"),
            *ColumnMetadata::metadataFromString("STRING", "col2"),
            *ColumnMetadata::metadataFromString("FLOAT", "col3") });

    auto main = std::make_shared<RawTable>(cols);
    for (size_t i=0; i < 100; ++i) {
      hyrise::storage::rawtable::RowHelper rh(cols);
      rh.set<hyrise_int_t>(0, i);
      rh.set<hyrise_string_t>(1, "MeinNameIstSlimShady" + std::to_string(i));
      rh.set<hyrise_float_t>(2, 1.1*i);
      unsigned char *data = rh.build();
      main->appendRow(data);
      free(data);
    }
    return main;
  }
コード例 #2
0
ファイル: UserInterface.cpp プロジェクト: pytton/fluidUI.new
//below fills the table with objects:
void WidgetTable::SetSize(int newrows, int newcols, WidgetTable * mytable)
{
	rows(newrows);
	cols(newcols);
	begin();		// start adding widgets to group
	{
		for (int r = 0; r<newrows; r++)
		{
			for (int c = 0; c<newcols; c++)
			{
				int X, Y, W, H;
				find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
				char s[40];
				//below decides what is put into table:
				//r is row and c is col
				if (c != 0 && c != 1 && c != 2 && c != 3) //this used to be ( c & 1) -bitwise comparison				
				{
					// Create the input widgets
					//sprintf(s, "%d.%d", r, c);
					Fl_Input *in = new Fl_Input(X, Y, W, H);
					//in->value(s);
				}
				else 
				{
					// Create the light buttons
					sprintf(s, "%d/%d ", r, c);
					My_fl_button *butt = new My_fl_button(X, Y, W, H, strdup(s));
					//Fl_Light_Button *butt = new Fl_Light_Button(X, Y, W, H, strdup(s));
					butt->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE);
					butt->callback(button_cb, (void*)mytable);
					//butt->value(((r + c * 2) & 4) ? 1 : 0);	//this sets the light on or off for Fl_Light_Button
					if (c == 0) butt->label("B LMT");
					if (c == 1) butt->label("B STP");
					if (c == 2) butt->label("S LMT");
					if (c == 3) butt->label("S STP");
					butt->x_pos = c;
					butt->y_pos = r;
				}

			}
		}
	}
	end();

}
コード例 #3
0
bool isValidSudoku2(vector<vector<char> > &board) {//极其巧妙的方法,慢慢消化
    // Start typing your C/C++ solution below
    // DO NOT write int main() function
    vector<vector<bool> > rows(9, vector<bool>(9, false));
    vector<vector<bool> > cols(9, vector<bool>(9, false));
    vector<vector<bool> > blocks(9, vector<bool>(9, false));

    for (int i = 0; i < 9; ++i) {
        for (int j = 0; j < 9; ++j) {
            if (board[i][j] == '.') continue;
            int c = board[i][j] - '1';
            if (rows[i][c] || cols[j][c] || blocks[i - i % 3 + j / 3][c])
                return false;
            rows[i][c] = cols[j][c] = blocks[i - i % 3 + j / 3][c] = true;
        }
    }
    return true;
}
コード例 #4
0
ファイル: catalog_view.cpp プロジェクト: peter-x/booxsdk
bool CatalogView::atRightEdge(int current)
{
    if (col(current) >= cols() - 1)
    {
        return true;
    }

    ++current;
    if (current >= visibleSubItems().size())
    {
        return true;
    }
    if (visibleSubItems().at(current)->data())
    {
        return false;
    }
    return true;
}
コード例 #5
0
ファイル: bch2bps.c プロジェクト: fb/jasper-xcsoar
	int /* entry point */
bch2bps(projUV a, projUV b, projUV **c, int nu, int nv) {
	projUV **d;
	int i;

	if (nu < 1 || nv < 1 || !(d = (projUV **)vector2(nu, nv, sizeof(projUV))))
		return 0;
	/* do rows to power series */
	for (i = 0; i < nu; ++i) {
		rows(c[i], d[i], nv);
		rowshft(a.v, b.v, d[i], nv);
	}
	/* do columns to power series */
	cols(d, c, nu, nv);
	colshft(a.u, b.u, c, nu, nv);
	freev2((void **) d, nu);
	return 1;
}
コード例 #6
0
//+-------------------------------------------------------------------------------
//|
//| NAME:
//|    sqlite_callback()
//|
//| PARAMETERS:
//|    data      (I) - The output data structure where query data returned from
//|                    the SQLite database will be written.
//|    argc      (I) - The number of rows returned from the database.
//|    argv      (I) - The actual contents of the rows returned from the database.
//|    azColName (I) - The list of column names returned from the database.
//|
//| DESCRIPTION:
//|    This is a callback method used by the query function to parse the results
//|    of the query and store them in a resultset object.
//|
//| RETURNS:
//|    0 for now because this is what sqlite3_exec() requires.
//|
//+-------------------------------------------------------------------------------
int sqlite_callback(void* data, int argc, char **argv, char **azColName)
{
    int i;
    sqllite_resultset_t* rs = (sqllite_resultset_t*)data;
    //QVector<sqllite_col_t> cols(argc);
    sqllite_col_t col;
    QVector<sqllite_col_t> cols(10);

    for(i=0; i<argc; i++)
    {
        col.value = argv[i] ? argv[i] : "NULL";
        col.name  = azColName[i] ? azColName[i] : "NULL";
        cols[i] = col;
    }
    rs->rows.append(cols);

    return 0;
}
コード例 #7
0
ファイル: Matrix1.cpp プロジェクト: mejwaller/numanal
float FloatMatrix::maxrowsum_Norm()
{
    float res = 0.0;
    float max = res;
    for(unsigned long int i = 0; i< rows();i++)
    {
        res = 0.0;
        for(unsigned long int j = 0; j<cols();j++)
        {
            res+=fabs((*this)(i,j));
        }
        if(res>max)
        {
            max = res;
        }
    }
    return max;
}
コード例 #8
0
void CrsMatrixWrapper<ST>::add(const std::vector<LO>& rowIdx,
                               const std::vector<ST>& array)
{
    const size_t emSize = rowIdx.size();
    std::vector<LO> cols(emSize);
    std::vector<ST> vals(emSize);
    for (size_t i = 0; i < emSize; i++) {
        const LO row = rowIdx[i];
        if (row <= maxLocalRow) {
            for (int j = 0; j < emSize; j++) {
                const LO col = rowIdx[j];
                cols[j] = col;
                const size_t srcIdx = j * emSize + i;
                vals[j] = array[srcIdx];
            }
            mat.sumIntoLocalValues(row, cols, vals);
        }
    }
}
コード例 #9
0
ファイル: eigen.hpp プロジェクト: HongLi15/amgcl
    /// Copy matrix from builtin backend.
    static boost::shared_ptr<matrix>
    copy_matrix(boost::shared_ptr< typename builtin<real>::matrix > A, const params&)
    {
        const typename builtin<real>::matrix &a = *A;

        BOOST_AUTO(Aptr, a.ptr_data());
        BOOST_AUTO(Acol, a.col_data());
        BOOST_AUTO(Aval, a.val_data());

        return boost::shared_ptr<matrix>(
                new matrix(
                    rows(*A), cols(*A), nonzeros(*A),
                    const_cast<index_type*>(Aptr),
                    const_cast<index_type*>(Acol),
                    const_cast<value_type*>(Aval)
                    ),
                hold_host(A)
                );
    }
コード例 #10
0
void Matrix::deleteSelectedColumns()
{
	QVarLengthArray<int> cols(1);
	int n=0;
	for (int i=0; i<numCols(); i++)
	{
		if (isColumnSelected(i, true))
		{
			n++;
			cols.resize(n);
			cols[n-1]= i;
		}
	}

	// columns need to be removed from right to left
	for(int i=cols.count()-1; i>=0; i--)
		d_table->removeColumn(cols[i]);
	emit modifiedWindow(this);
}
コード例 #11
0
ファイル: space.c プロジェクト: RodrigoDePool/ProyProg
Space * space_ini()
{
    int   i;
    Space *s;
    s = (Space *) malloc(sizeof(Space));
    if (!s)
        return NULL;
    sId(s)      = -1;
    sDesc(s)    = NULL;
    lDesc(s)    = NULL;
    light(s)    = FALSE;
    isLocked(s) = FALSE;
    map(s)      = NULL;
    rows(s)     = -1;
    cols(s)     = -1;
    numdoors(s) = -1;
    doors(s)    = NULL;
    return s;
}
コード例 #12
0
ファイル: dl_base.cpp プロジェクト: killbug2004/Snippets
        /**
        Reference implementation with negation:

        T1 = join(T, T) by group_cols
        T2 = { (t1,t2) in T1 | t1[col] > t2[col] }
        T3 = { t1 | (t1,t2) in T2 }
        T4 = T \ T3

        The point of this reference implementation is to show
        that the minimum requires negation (set difference).
        This is relevant for fixed point computations.
        */
        virtual table_base * reference_implementation(const table_base & t) {
            relation_manager & manager = t.get_manager();
            scoped_ptr<table_join_fn> join_fn = manager.mk_join_fn(t, t, m_group_by_cols, m_group_by_cols);
            scoped_rel<table_base> join_table = (*join_fn)(t, t);

            table_base::iterator join_table_it = join_table->begin();
            table_base::iterator join_table_end = join_table->end();
            table_fact row;

            table_element i, j;

            for (; join_table_it != join_table_end; ++join_table_it) {
                join_table_it->get_fact(row);
                i = row[m_col];
                j = row[t.num_columns() + m_col];

                if (i > j) {
                    continue;
                }

                join_table->remove_fact(row);
            }

            unsigned_vector cols(t.num_columns());
            for (unsigned k = 0; k < cols.size(); ++k) {
                cols[k] = cols.size() + k;
                SASSERT(cols[k] < join_table->num_columns());
            }

            scoped_ptr<table_transformer_fn> project_fn = manager.mk_project_fn(*join_table, cols);
            scoped_rel<table_base> gt_table = (*project_fn)(*join_table);

            for (unsigned k = 0; k < cols.size(); ++k) {
                cols[k] = k;
                SASSERT(cols[k] < t.num_columns());
                SASSERT(cols[k] < gt_table->num_columns());
            }

            table_base * result = t.clone();
            scoped_ptr<table_intersection_filter_fn> diff_fn = manager.mk_filter_by_negation_fn(*result, *gt_table, cols, cols);
            (*diff_fn)(*result, *gt_table);
            return result;
        }
コード例 #13
0
ファイル: Box.cpp プロジェクト: liuyepku/TemporalPattern
void Box<DATA>::include
  (
  const DATA& ar_DataVector
  )
  {
  // enlarge bbox if necessary
  adjust(max(rows(),ar_DataVector.rows()),max(cols(),ar_DataVector.cols()));

  typename DATA::value_type value;
  for (int r=0;r<ar_DataVector.rows();++r)
    {
    for (int c=0;c<ar_DataVector.cols();++c)
      {
      value = ar_DataVector(r,c);
      if (lowerBound(r,c) > value) { lowerBound(r,c) = value; }
      if (upperBound(r,c) < value) { upperBound(r,c) = value; }
      } // for c
    } // for r
  }
コード例 #14
0
ファイル: matrix.cpp プロジェクト: mikanradojevic/sdkpub
void Matrix<T>::submatrix(int sr, int sc, Matrix<T> &a)
{
  int rwz,coz,i,j;
  
  if ( this->rows() % a.rows() != 0 || this->cols() % a.cols() != 0 || this->rows() < a.rows() || this->cols() < a.cols() )
    {
#ifdef USE_EXCEPTION
      throw WrongSize2D(this->rows(),this->cols(),a.rows(),a.cols()) ;
#else
      Error error("Matrix<T>::submatrix");
      error << "Matrix and submatrix incommensurate" ;
      error.fatal() ;
#endif
    }
  
  if ( sr >= this->rows()/a.rows() || sr < 0 || sc >= this->cols()/a.cols() || sc < 0 )
    {
#ifdef USE_EXCEPTION
      throw OutOfBound2D(sr,sc,0,this->rows()/a.rows()-1,0,this->cols()/a.cols()-1) ;
#else
      Error error("Matrix<T>::submatrix");
      error << "Submatrix location out of bounds.\nrowblock " << sr << ", " << rows()/a.rows() << " colblock " << sc << ", " << a.cols() << endl ;
      error.fatal() ;
#endif
    }
  rwz = sr*a.rows();
  coz = sc*a.cols();
  
#ifdef COLUMN_ORDER
  for ( i = a.rows()-1; i >= 0; --i )
    for(j=a.cols()-1;j>=0;--j)
      this->elem(i+rwz,j+coz) = a(i,j) ;
#else
  T *ptr, *aptr ;
  aptr = a.m - 1;
  for ( i = a.rows()-1; i >= 0; --i )
    {
      ptr = &m[(i+rwz)*cols()+coz]-1 ;
      for ( j = a.cols(); j > 0; --j)
	*(++ptr) = *(++aptr) ;
    }  
#endif
}
コード例 #15
0
ファイル: space.c プロジェクト: RodrigoDePool/ProyProg
Space * space_ini(){
	int i;
	Space *s;
	s = (Space *) malloc (sizeof(Space));
	if(!s)
		return NULL;
	sId(s) = -1;
	for(i = 0; i < 8; i++)
		neighbour(s)[i] = -1;
	sDesc(s) = NULL;
	lDesc(s) = NULL;
	light(s) = FALSE;
	isLocked(s) = FALSE;
	map(s) = NULL;
	rows(s) = -1;
	cols(s) = -1;
	return s;

}
コード例 #16
0
ファイル: boost_ullmann.hpp プロジェクト: alvatar/snippets
 bool ullmann(const Graph& g1, const Graph& g2,
 VertexLabeling& vertex_labeling, EdgeLabeling& edge_labeling, BackInsertionSequence& F) {
   typedef typename graph_traits<Graph>::vertex_descriptor    vertex_t;
   typedef ::boost::numeric::ublas::matrix<bool>   matrix_t;
   size_t rows(num_vertices(g1));
   size_t cols(num_vertices(g2));
   matrix_t M(rows,cols);
   // initialize the matrix:
   for (int i=0; i<rows; ++i)
     for (int j=0; j<cols; ++j)
       if(vertex_labeling(i,j)) M(i,j)=1;
   size_t    i(0);
   try {
     detail::backtrack(g1,g2,i,M,F,rows,cols,edge_labeling);
   } catch(ullmann_throw) {
     return true;
   }
   return false;
 }
コード例 #17
0
ファイル: ValidSudoku.cpp プロジェクト: Amywyc/leetcode-1
 bool isValidSudoku(vector<vector<char>> &board) {
     vector<vector<bool>> rows(9, vector<bool>(9, false));
     vector<vector<bool>> cols(9, vector<bool>(9, false));
     vector<vector<bool>> cells(9, vector<bool>(9, false));
     
     for (int i = 0; i < 9; i++) {
         for (int j = 0; j < 9; j++) {
             if (board[i][j] != '.') {
                 int x = board[i][j] - '1';
                 if (rows[i][x] || cols[j][x] || cells[(j/3)*3+i/3][x]) {
                     return false;
                 }
                 rows[i][x] = true;
                 cols[j][x] = true;
                 cells[(j/3)*3+i/3][x] = true;
             }
         }
     }
     return true;
 }
コード例 #18
0
int main(){

    long long n, m; scanf("%lld %lld\n", &n, &m);
    std::vector<bool> rows(n + 1, 0);
    std::vector<bool> cols(n + 1, 0);
    long long takenRows(0), takenCols(0);

    long long safe(n * n);

    while(m--){
        long long r, c; scanf("%lld %lld\n", &r, &c);
        if(!rows[r]){rows[r] = 1; ++takenRows; safe -= (n - takenCols);}
        if(!cols[c]){cols[c] = 1; ++takenCols; safe -= (n - takenRows);}
        printf("%lld ", safe);
    }

    puts("");

    return 0;
}
コード例 #19
0
ファイル: GeneralAligner.hpp プロジェクト: npge/npge
 void make_frame() const {
     at(-1, -1) = 0;
     track(-1, -1) = STOP;
     for (int row = 0; row < rows(); row++) {
         if (local()) {
             at(row, -1) = 0;
         } else {
             at(row, -1) = (row + 1) * gap_penalty();
         }
         track(row, -1) = ROW_INC;
     }
     for (int col = 0; col < cols(); col++) {
         if (local()) {
             at(-1, col) = 0;
         } else {
             at(-1, col) = (col + 1) * gap_penalty();
         }
         track(-1, col) = COL_INC;
     }
 }
コード例 #20
0
ファイル: Fl_Table.C プロジェクト: benschneider/Spyview
// Table resized: recalc internal data
//    Call this whenever the window is resized.
//    Recalculates the scrollbar sizes.
//    Makes no assumptions about any pre-initialized data.
//
void Fl_Table::table_resized()
{
    table_h = row_scroll_position(rows());
    table_w = col_scroll_position(cols());

    recalc_dimensions();

    // Recalc scrollbar sizes
    //    Clamp scrollbar value() after a resize.
    //    Resize scrollbars to enforce a constant trough width after a window resize.
    //
    {
        float vscrolltab = ( table_h == 0 || tih > table_h ) ? 1 : (float)tih / table_h;
        float hscrolltab = ( table_w == 0 || tiw > table_w ) ? 1 : (float)tiw / table_w;

	vscrollbar->bounds(0, table_h-tih);
	vscrollbar->precision(10);
	vscrollbar->slider_size(vscrolltab);
	vscrollbar->resize(wix+wiw-SCROLLBAR_SIZE, wiy,
			   SCROLLBAR_SIZE, 
			   wih - ((hscrollbar->visible())?SCROLLBAR_SIZE:0));
	vscrollbar->Fl_Valuator::value(vscrollbar->clamp(vscrollbar->value()));	

	hscrollbar->bounds(0, table_w-tiw);
	hscrollbar->precision(10);
        hscrollbar->slider_size(hscrolltab);
	hscrollbar->resize(wix, wiy+wih-SCROLLBAR_SIZE,
			   wiw - ((vscrollbar->visible())?SCROLLBAR_SIZE:0), 
			   SCROLLBAR_SIZE);
	hscrollbar->Fl_Valuator::value(hscrollbar->clamp(hscrollbar->value()));
    }

    // Tell FLTK child widgets were resized
    Fl_Group::init_sizes();

    // Recalc top/bot/left/right
    table_scrolled();

    // DO *NOT* REDRAW -- LEAVE THIS UP TO THE CALLER
    // redraw();
}
コード例 #21
0
ファイル: Solution.cpp プロジェクト: comzyh/solution4leetcode
 void setZeroes(vector<vector<int>>& matrix) {
     if (matrix.size() == 0) {
         return;
     }
     vector<int> rows(matrix.size(), 0), cols(matrix[0].size(), 0);
     for (size_t row = 0; row < matrix.size(); row ++) {
         for (size_t col = 0; col < matrix[0].size(); col ++) {
             if (matrix[row][col] == 0) {
                 rows[row] = 1;
                 cols[col] = 1;
             }
         }
     }
     for (size_t row = 0; row < matrix.size(); row ++) {
         for (size_t col = 0; col < matrix[0].size(); col ++) {
             if (rows[row] || cols[col]) {
                 matrix[row][col] = 0;
             }
         }
     }
 }
コード例 #22
0
ファイル: Precode_Matrix.cpp プロジェクト: lanouyu/libRaptorQ
void Precode_Matrix::init_LDPC2 (const uint16_t skip, const uint16_t rows,
															const uint16_t cols)
{
	// this submatrix has two consecutive "1" in the first row, first two
	// colums, and then every other row is the previous right shifted.

	// You won't find this easily on the rfc, but you can see this in the book:
	//  Raptor Codes Foundations and Trends in Communications
	//	and Information Theory
	auto sub_mtx = A.block (0, skip, rows, cols);
	for (uint16_t row = 0; row < sub_mtx.rows(); ++row) {
		uint16_t start = row % cols;
		for (uint16_t col = 0; col < sub_mtx.cols(); ++col) {
			if (col == start || col == (start + 1) % cols) {
				sub_mtx (row, col) = 1;
			} else {
				sub_mtx (row, col) = 0;
			}
		}
	}
}
コード例 #23
0
void crosshair_object::compute_geometry_() {
    std::vector<float> cols(colors_.size());
    std::transform(colors_.begin(), colors_.end(), cols.begin(), [&] (const Eigen::Vector4f& c) { return renderable::color_to_rgba(c); });

    vertex_data_ = vertex_data_t::Zero(6 * cols.size(), 9);
    index_data_ = index_data_t(6 * cols.size(), 1);
    for (uint32_t i = 0; i < cols.size(); ++i) {
        Eigen::RowVector3f origin = vertices_[i].transpose();
        vertex_data_.block(i*6 + 0, 0, 1, 3) = origin - size_ * Eigen::RowVector3f::UnitX();
        vertex_data_.block(i*6 + 1, 0, 1, 3) = origin + size_ * Eigen::RowVector3f::UnitX();
        vertex_data_.block(i*6 + 2, 0, 1, 3) = origin - size_ * Eigen::RowVector3f::UnitY();
        vertex_data_.block(i*6 + 3, 0, 1, 3) = origin + size_ * Eigen::RowVector3f::UnitY();
        vertex_data_.block(i*6 + 4, 0, 1, 3) = origin - size_ * Eigen::RowVector3f::UnitZ();
        vertex_data_.block(i*6 + 5, 0, 1, 3) = origin + size_ * Eigen::RowVector3f::UnitZ();
        for (uint32_t j = 0; j < 6; ++j) {
            index_data_(i*6 + j, 0) = i*6 + j;
            vertex_data_(i*6 + j, 3) = cols[i];
        }
    }
    compute_bounding_box_();
}
コード例 #24
0
void compute_sketch_matrix(sketch_t sketch, const DistMatrixType &A,
                           DistMatrixType &result) {

    std::vector<size_t> row_idx = sketch.getRowIdx();
    std::vector<double> row_val = sketch.getRowValues();

    // PI generated by random number gen
    size_t sketch_size = row_val.size();
    mpi_vector_t cols(sketch_size);
    mpi_vector_t rows(sketch_size);
    mpi_vector_t vals(sketch_size);

    for(size_t i = 0; i < sketch_size; ++i) {
        cols.SetElement(i, i);
        rows.SetElement(i, row_idx[i]);
        vals.SetElement(i, row_val[i]);
    }

    result = DistMatrixType(result.getnrow(), result.getncol(),
                            rows, cols, vals);
}
コード例 #25
0
ファイル: FLOCK.cpp プロジェクト: Kthulhu/EnjaParticles
//----------------------------------------------------------------------
void FLOCK::pushParticles(vector<float4> pos, vector<float4> vels, float4 color,float mass)
{
    int nn = pos.size();

    // if we have reach max num of particles, then return
    if (num + nn > max_num) {return;}

    vector<float4> cols(nn);
    fill(cols.begin(), cols.end(),color); //BLENDER

#ifdef CPU
    std::copy(pos.begin(), pos.end(), positions.begin()+num);
#endif

#ifdef GPU
    glFinish();
    if(!acquiredGL)
    {
        cl_position_u.acquire();
        cl_color_u.acquire();
        cl_velocity_u.acquire();
    }

    cl_position_u.copyToDevice(pos, num);
    cl_color_u.copyToDevice(cols, num);
    cl_velocity_u.copyToDevice(vels, num);

    settings->SetSetting("num_particles", num+nn);
    updateParams();

    if(!acquiredGL){
        cl_velocity_u.release();
        cl_color_u.release();
        cl_position_u.release();
    }

    num += nn;  //keep track of number of particles we use
#endif
}
コード例 #26
0
ファイル: videopreview.cpp プロジェクト: buscher/SMPlayer2
void VideoPreview::loadSettings()
{
    qDebug("VideoPreview::loadSettings");

    set->beginGroup("videopreview");

    setCols(set->value("columns", cols()).toInt());
    setRows(set->value("rows", rows()).toInt());
    setInitialStep(set->value("initial_step", initialStep()).toInt());
    setMaxWidth(set->value("max_width", maxWidth()).toInt());
    setDisplayOSD(set->value("osd", displayOSD()).toBool());
    setExtractFormat((ExtractFormat) set->value("format", extractFormat()).toInt());
    save_last_directory = set->value("save_last_directory", save_last_directory).toBool();
    last_directory = set->value("last_directory", last_directory).toString();

    setVideoFile(set->value("filename", videoFile()).toString());
    setDVDDevice(set->value("dvd_device", DVDDevice()).toString());

    toggleInfoAct->setChecked(set->value("show_info", true).toBool());

    set->endGroup();
}
コード例 #27
0
ファイル: ParpackSolver.cpp プロジェクト: jwgcarlson/OPSEC
ParpackSolver::ParpackSolver(int n_, MatrixFactory& matfact) {
    n = n_;

    int nprocs, me;
    Cblacs_pinfo(&me, &nprocs);
    nloc = n/nprocs + (me < (n % nprocs));

    /* Initialize BLACS process grid */
    pcontext = new slp::Context(nprocs, 1);

    /* Initialize matrix descriptor */
    Adesc = pcontext->new_descriptor(n, n, divup(n,nprocs), n);
    assert(nloc == Adesc->num_local_rows());
    assert(n == Adesc->num_local_cols());

    /* Allocate local memory for matrix $A$ */
    Avalues = (real*) opsec_malloc(Adesc->local_size() * sizeof(real));

    /* Fill in local matrix values */
    int nrows = Adesc->num_local_rows();
    int ncols = Adesc->num_local_cols();
    std::vector<int> rows(nrows), cols(ncols);
    for(int i = 0; i < nrows; i++)
        rows[i] = Adesc->row_l2g(i);
    for(int j = 0; j < ncols; j++)
        cols[j] = Adesc->col_l2g(j);
    matfact.ComputeMatrixValues(rows, cols, Avalues, Adesc->lld);

    /* Set default PARPACK parameters */
    nconv = -1;
    tol = 1e-5;
    maxitr = 1000;
    ncv = -1;

    /* These are initialized upon calling Solve() */
    xdesc = NULL;
    Bdesc = NULL;
    Bvalues = NULL;
}
コード例 #28
0
QString Matrix::toString () const
{
  QString out;
  QTextStream str (&out);

  str << "(";
  for (int row = 0; row < rows (); row++) {
    if (row > 0) {
      str << ", ";
    }
    str << "(";
    for (int col = 0; col < cols (); col++) {
      if (col > 0) {
        str << ", ";
      }
      str << get (row, col);
    }
    str << ")";
  }
  str << ")";

  return out;
}
コード例 #29
0
Basic2DArray<T>& Basic2DArray<T>::operator=(const Basic2DArray<T> &a)
{
  int i;
  
  if ( this == &a )
    return *this;
  
  if(rows() != a.rows() || cols() != a.cols()){
    resize(a.rows(),a.cols()) ;
  }

  T *p1,*pa ;
  int sz = a.rows()*a.cols() ;
  p1 = m-1 ;
  pa = a.m-1 ;

  for (i = sz; i > 0; --i)
      *(++p1) = *(++pa) ;
  
  by_columns = a.by_columns;
  width = a.width ;
  
  return *this;
}
コード例 #30
0
void
dft_HardSphereA22_Tpetra_Operator<Scalar,MatrixType>::
formA22Matrix
()
{
    if (A22Matrix_ == Teuchos::null) {
        A22Matrix_ = rcp(new MAT(getRangeMap(), 1));
        A22Matrix_->setObjectLabel("HardSphereA22::A22Matrix");
    }
    LocalOrdinal numRows = getRangeMap()->getNodeNumElements();
    Teuchos::ArrayRCP<const Scalar> vectorValues = densityOnDensityMatrix_->get1dView();
    for (LocalOrdinal i=OTLO::zero(); i<numRows; i++) {
        GlobalOrdinal row = A22Matrix_->getRowMap()->getGlobalElement(i);
        Scalar value = vectorValues[i];
        GlobalOrdinal col = row;
        Array<GlobalOrdinal> cols(1);
        Array<MatScalar> vals(1);
        cols[0] = col;
        vals[0] = Teuchos::as<MatScalar>(value);
        A22Matrix_->insertGlobalValues(row, cols, vals);
    }
    A22Matrix_->fillComplete();

}