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


C++ row函数代码示例

本文整理汇总了C++中row函数的典型用法代码示例。如果您正苦于以下问题:C++ row函数的具体用法?C++ row怎么用?C++ row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: a

void quaterN::transition0(const quater& aa, const quater& bb, int duration)
{
	quater a(aa);
	quater b(bb);
	quater qid;
	qid.identity();
	a.align(qid);
	b.align(qid);
	// kovar paper (prefer identity quaternion (more safe))
	setSize(duration);

	float totalTime=duration+1;
	float currTime;
	quater c, d, qi;
	qi.identity();
	for(int i=0; i<duration; i++)
	{
		currTime=(float)(i+1)/totalTime;
		float t=-2.f*CUBIC(currTime)+3.f*SQR(currTime);
		c.slerp(a, qi, t);
		d.slerp(qi, b, t);
		row(i).slerp(c, d, currTime);
	}
}
开发者ID:VitorRetamal,项目名称:papercrop,代码行数:24,代码来源:quaterN.cpp

示例2: validate_regex

static void validate_regex( const music_details& desc, int bells )
{
  static string allowed;
  if ( allowed.empty() ) {
    allowed.append( row(bells).print() );
    allowed.append("*?[]");
  }

  string tok( desc.get() );

  if ( tok.find_first_not_of( allowed ) != string::npos )
    throw runtime_error( make_string() << "Illegal regular expression: " 
			 << tok );

  bool inbrack(false);
  for ( string::const_iterator i(tok.begin()), e(tok.end()); i!=e; ++i ) 
    switch (*i) {
    case '[':
      if ( inbrack ) 
	throw runtime_error( "Unexpected '[' in regular expressions" );
      inbrack = true;
      break;
    case ']':
      if ( !inbrack )
	throw runtime_error( "Unexpected ']' in regular expressions" );
      inbrack = false;
      break;
    case '*': case '?':
      if ( inbrack )
	throw runtime_error( "Cannot use '*' or '?' in a [] block "
			     "of a regular expression" );
      break;
    }

  // TODO: Check for multiple occurances of the same bell
}
开发者ID:brucegentles,项目名称:ringinglib,代码行数:36,代码来源:expression.cpp

示例3: codec

void SubsetSingleBench::onDraw(int n, SkCanvas* canvas) {
    // When the color type is kIndex8, we will need to store the color table.  If it is
    // used, it will be initialized by the codec.
    int colorCount;
    SkPMColor colors[256];
    if (fUseCodec) {
        for (int count = 0; count < n; count++) {
            SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate()));
            const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
            SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
            codec->startScanlineDecode(info, nullptr, colors, &colorCount);

            SkBitmap bitmap;
            SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
            alloc_pixels(&bitmap, subsetInfo, colors, colorCount);

            codec->skipScanlines(fOffsetTop);
            uint32_t bpp = info.bytesPerPixel();
            for (uint32_t y = 0; y < fSubsetHeight; y++) {
                codec->getScanlines(row.get(), 1, 0);
                memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp,
                        fSubsetWidth * bpp);
            }
        }
    } else {
        for (int count = 0; count < n; count++) {
            SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
            int width, height;
            decoder->buildTileIndex(fStream->duplicate(), &width, &height);
            SkBitmap bitmap;
            SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWidth,
                    fSubsetHeight);
            decoder->decodeSubset(&bitmap, rect, fColorType);
        }
    }
}
开发者ID:picmonkey,项目名称:skia,代码行数:36,代码来源:SubsetSingleBench.cpp

示例4: itemAt

void EventView::mouseDoubleClickEvent(QMouseEvent *event)
{
	QListWidgetItem *selectedItem = itemAt(event->pos());
	if (selectedItem != NULL)
	{
		int selectedRow = row(selectedItem);
		if (!item(selectedRow)->text().contains(QRegExp("^\\s*::")))
		{
			BaseEvent *eventToAdd = BaseEvent::browseEvents(currentEvent->getBaseType(), callerID, callerType);
			if (eventToAdd != NULL)
			{
				int row = currentRow();
				int eventsID = childEventIDAtRow(row);
				int parentID = eventsParentIDAtRow(row);
				int childTypeID = childEventTypeIDAtRow(row);
				eventList[parentID]->addChildEvent(eventToAdd, eventsID, childTypeID);
				updateView();
				eventList.clear();
				eventList = currentEvent->getEventPointers();
				setCurrentRow(row);
			}
		}
	}
}
开发者ID:timdetering,项目名称:openrpgmaker,代码行数:24,代码来源:eventview.cpp

示例5: row

void SolverFormulacaoPadrao::UpdateConsUpperBound(double upper) {
  // constraint
  ConstraintFormulacaoPadrao cons;
  // variable
  VariableFormulacaoPadrao var;

  // creates the constraint
  cons.reset();
  cons.set_type(ConstraintFormulacaoPadrao::C_UPPER_BOUND);
  ConstraintFormulacaoPadraoHash::iterator it = cHash_.find(cons);

  if (it == cHash_.end()) {
    cHash_[cons] = lp_->getNumRows();
    int nnz = problem_data_->num_tasks();
    OPT_ROW row(nnz, OPT_ROW::LESS, upper, (char*) cons.ToString().c_str());

    // adds each variable
    for (int i = 0; i < problem_data_->num_machines(); ++i) {
      for (int j = 0; j < problem_data_->num_tasks(); ++j) {
        var.reset();
        var.set_type(VariableFormulacaoPadrao::X_ij);
        var.set_machine(i);
        var.set_task(j);
        VariableFormulacaoPadraoHash::iterator vit = vHash_.find(var);

        //CHECK_NE(vit, vHash_.end());

        double cost = problem_data_->cost(i, j);
        row.insert(vit->second, cost);
      }
    }
    lp_->addRow(row);
  } else {
    lp_->chgRHS(it->second, upper);
  }
}
开发者ID:danielamaral,项目名称:GAP,代码行数:36,代码来源:SolverFormulacaoPadrao.cpp

示例6: main

int main (int argc, char **argv){
  int number;
  int height;
  int position = 2;
  int space = 0;
  int space2 =0;
  int space3 = 0;
  /*checking if there are arguments or if the argument is negative*/
  if (argc == 1 || argv[1][0] == '-'){
    return 0;
  }
  number = char_to_int(argv);
  /*Iterating though the first part of the cross*/
  for(height = 0; height < number/2; height ++){
    space = spaces(space);
    position = row(number, position);
    space2 = spaces2(space2);
  }
  /*Printing an x in the middle if the number is odd*/
  if (number % 2 != 0){
    space = spaces(space);
    write(1, "X", 1);
    space2 = spaces2(space2);
    space2 --;
  }
  space3 = space2;
  /*This is done so that the spaces before the symbles start form the middle of the second part of the cross*/
  space = number/2 - 1;
  position -=1;
  for(height = 0; height < number/2; height ++){
  space = spaces(space) - 2;
  position =row2(number, position);
  space3 = spaces3(space3);
  }
  return 0;
}
开发者ID:stvngrcia,项目名称:holbertonschool-low_level_programming,代码行数:36,代码来源:main.c

示例7: test_math_matrix_mult_TCRRMV

void test_math_matrix_mult_TCRRMV(void)
{
	T d1[M*N];

	for(unsigned i=0; i<(M*N); ++i)
	{
		d1[i] = T(std::rand()%10000)/2;
	}

	T d2[N*K];

	for(unsigned i=0; i<(N*K); ++i)
	{
		d2[i] = T(std::rand()%10000)/2;
	}

	auto m1 = eagine::math::matrix<T, N, M, RM1, V>::from(d1, M*N);
	auto m2 = eagine::math::matrix<T, K, N, RM2, V>::from(d2, N*K);

	eagine::math::matrix<T, K, M, RM1, V> m = multiply(m1, m2);
	(void)m;

	for(unsigned i=0; i<M; ++i)
	for(unsigned j=0; j<K; ++j)
	{
		T e = T(0);

		for(unsigned k=0; k<N; ++k)
		{
			e += row(m1, i)[k]*column(m2, j)[k];
		}

		BOOST_CHECK_EQUAL(get_cm(m, j, i), e);
		BOOST_CHECK_EQUAL(get_rm(m, i, j), e);
	}
}
开发者ID:deranen,项目名称:oglplu2,代码行数:36,代码来源:math_matrix_3_r.cpp

示例8: printline

void CUI_LoadMsg::draw(Drawable *S) {
    int i;

    char *str[] = { "Please wait, loading... |",
                    "Please wait, loading... /",
                    "Please wait, loading... -",
                    "Please wait, loading... \\"
    };

    if (S->lock()==0) {
        S->fillRect(col(15),row(20),640-col(15)-1,row(25)-1,COLORS.Background);
        printline(col(15),row(24),148,50,COLORS.Lowlight,S);
        for (i=20;i<25;i++) {
            printchar(col(15),row(i),145,COLORS.Highlight,S);
            printchar(col(64),row(i),146,COLORS.Lowlight,S);
        }
        printline(col(15),row(20),143,50,COLORS.Highlight,S);
        print(col(textcenter(str[strselect],40)),row(22),str[strselect],COLORS.Text,S);
        S->unlock();
        need_refresh = 0;
        updated++;
    }
}
开发者ID:cmicali,项目名称:ztracker,代码行数:23,代码来源:CUI_LoadMsg.cpp

示例9: CHECK_INVARIANT

PyObject *getEuclideanDistMat(python::object descripMat) {
    // Bit of a pain involved here, we accept three types of PyObjects here
    // 1. A Numeric Array
    //     - first find what 'type' of entry we have (float, double and int is all we recognize for now)
    //     - then point to contiguous piece of memory from the array that contains the data with a type*
    //     - then make a new type** pointer so that double index into this contiguous memory will work
    //       and then pass it along to the distance calculator
    // 2. A list of Numeric Vector (or 1D arrays)
    //     - in this case wrap descripMat with a PySequenceHolder<type*> where type is the
    //       type of entry in vector (accepted types are int, double and float
    //     - Then pass the PySequenceHolder to the metrci calculator
    // 3. A list (or tuple) of lists (or tuple)
    //     - In this case other than wrapping descripMat with a PySequenceHolder
    //       each of the indivual list in there are also wrapped by a PySequenceHolder
    //     - so the distance calculator is passed in a "PySequenceHolder<PySequenceHolder<double>>"
    //     - FIX: not that we always convert entry values to double here, even if we passed
    //       in a list of list of ints (or floats). Given that lists can be heterogeneous, I do not
    //       know how to ask a list what type of entries if contains.
    //
    //  OK my brain is going to explode now

    // first deal with situation where we have an Numeric Array
    PyObject *descMatObj = descripMat.ptr();
    PyArrayObject *distRes;
    if (PyArray_Check(descMatObj)) {
        // get the dimensions of the array
        int nrows = ((PyArrayObject *)descMatObj)->dimensions[0];
        int ncols = ((PyArrayObject *)descMatObj)->dimensions[1];
        int i;
        CHECK_INVARIANT((nrows > 0) && (ncols > 0), "");

        npy_intp dMatLen = nrows*(nrows-1)/2;

        // now that we have the dimensions declare the distance matrix which is always a
        // 1D double array
        distRes = (PyArrayObject *)PyArray_SimpleNew(1, &dMatLen, NPY_DOUBLE);

        // grab a pointer to the data in the array so that we can directly put values in there
        // and avoid copying :
        double *dMat = (double *)distRes->data;

        PyArrayObject *copy;
        copy = (PyArrayObject *)PyArray_ContiguousFromObject(descMatObj,
                ((PyArrayObject *)descMatObj)->descr->type_num,
                2,2);
        // if we have double array
        if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_DOUBLE) {
            double *desc = (double *)copy->data;

            // REVIEW: create an adaptor object to hold a double * and support
            //  operator[]() so that we don't have to do this stuff:

            // here is the 2D array trick this so that when the distance calaculator
            // asks for desc2D[i] we basically get the ith row as double*
            double **desc2D = new double*[nrows];
            for (i = 0; i < nrows; i++) {
                desc2D[i] = desc;
                desc += ncols;
            }
            MetricMatrixCalc<double**, double*> mmCalc;
            mmCalc.setMetricFunc(&EuclideanDistanceMetric<double *, double *>);
            mmCalc.calcMetricMatrix(desc2D, nrows, ncols, dMat);

            delete [] desc2D;
            // we got the distance matrix we are happy so return
            return PyArray_Return(distRes);
        }

        // if we have a float array
        else if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_FLOAT) {
            float* desc = (float *)copy->data;
            float **desc2D = new float*[nrows];
            for (i = 0; i < nrows; i++) {
                desc2D[i] = desc;
                desc += ncols;
            }
            MetricMatrixCalc<float**, float*> mmCalc;
            mmCalc.setMetricFunc(&EuclideanDistanceMetric<float *, float*>);
            mmCalc.calcMetricMatrix(desc2D, nrows, ncols, dMat);
            delete [] desc2D;
            return PyArray_Return(distRes);
        }

        // if we have an interger array
        else if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_INT) {
            int *desc = (int *)copy->data;
            int **desc2D = new int*[nrows];
            for (i = 0; i < nrows; i++) {
                desc2D[i] = desc;
                desc += ncols;
            }
            MetricMatrixCalc<int**, int*> mmCalc;
            mmCalc.setMetricFunc(&EuclideanDistanceMetric<int *, int*>);
            mmCalc.calcMetricMatrix(desc2D, nrows, ncols, dMat);
            delete [] desc2D;
            return PyArray_Return(distRes);
        }
        else {
            // unreconiged type for the matrix, throw up
            throw_value_error("The array has to be of type int, float, or double for GetEuclideanDistMat");
//.........这里部分代码省略.........
开发者ID:Jazzy2906,项目名称:rdkit,代码行数:101,代码来源:rdMetricMatrixCalc.cpp

示例10: art

void InfoShape::draw(const DrawBuf &buf) const
 {
  if( !pane ) return;

  Smooth::DrawArt art(buf);

  VColor text=enable?+cfg.text:+cfg.inactive;

  Point space=+cfg.space;

  // decor

  {
   MPane p(pane);

   MCoord width=+cfg.width;
   MCoord dx=Fraction(space.x)-width;
   MCoord dy=Fraction(space.y)-width;

   if( focus )
     {
      FigureBox fig(p.shrink(Fraction(space.x)/2,Fraction(space.y)/2));

      fig.loop(art,width,+cfg.focus);
     }

   if( xoff>0 )
     {
      FigureLeftMark fig(p,dx);

      fig.solid(art,text);
     }

   if( xoff<xoffMax )
     {
      FigureRightMark fig(p,dx);

      fig.solid(art,text);
     }

   if( yoff>0 )
     {
      FigureUpMark fig(p,dy);

      fig.solid(art,text);
     }

   if( yoff<yoffMax )
     {
      FigureDownMark fig(p,dy);

      fig.solid(art,text);
     }
  }

  // text

  {
   Pane inner=pane.shrink(space);

   if( !inner ) return;

   ulen count=info->getLineCount();
   ulen index=yoff;

   Font font=cfg.font.get();

   FontSize fs=font->getSize();

   DrawBuf tbuf=buf.cutRebase(inner);

   Pane row(-xoff,0,IntAdd(xoff,inner.dx),fs.dy);

   for(; index<count && row.y+row.dy<=inner.dy ;index++,row.y+=row.dy)
     {
      font->text(tbuf,row,TextPlace(AlignX_Left,AlignY_Top),info->getLine(index),text);
     }
  }
 }
开发者ID:SergeyStrukov,项目名称:CCore-2-xx,代码行数:79,代码来源:ShapeLib.InfoShape.cpp

示例11: benchmark_spmv_ccsr

std::pair<double,double> benchmark_spmv_ccsr(
        const vex::Context &ctx, vex::profiler<> &prof
        )
{
    // Construct matrix for 3D Poisson problem in cubic domain.
    const uint n = 128;
    const uint N = n * n * n;
    const uint M = 1024;

    double time_elapsed;

    const real h2i = (n - 1) * (n - 1);

    std::vector<size_t> idx;
    std::vector<size_t> row(3);
    std::vector<int>    col(8);
    std::vector<real>   val(8);

    std::vector<real>   X(n * n * n, static_cast<real>(1e-2));
    std::vector<real>   Y(n * n * n, 0);

    idx.reserve(n * n * n);

    row[0] = 0;
    row[1] = 1;
    row[2] = 8;

    col[0] = 0;
    val[0] = 1;

    col[1] = -static_cast<int>(n * n);
    col[2] = -static_cast<int>(n);
    col[3] =    -1;
    col[4] =     0;
    col[5] =     1;
    col[6] =     n;
    col[7] =  (n * n);

    val[1] = -h2i;
    val[2] = -h2i;
    val[3] = -h2i;
    val[4] =  h2i * 6;
    val[5] = -h2i;
    val[6] = -h2i;
    val[7] = -h2i;

    for(size_t k = 0; k < n; k++) {
        for(size_t j = 0; j < n; j++) {
            for(size_t i = 0; i < n; i++) {
                if (
                        i == 0 || i == (n - 1) ||
                        j == 0 || j == (n - 1) ||
                        k == 0 || k == (n - 1)
                   )
                {
                    idx.push_back(0);
                } else {
                    idx.push_back(1);
                }
            }
        }
    }

    size_t nnz = 6 * (n - 2) * (n - 2) * (n - 2) + n * n * n;

    // Transfer data to compute devices.
    vex::SpMatCCSR<real,int> A(ctx.queue(0), n * n * n, 2,
            idx.data(), row.data(), col.data(), val.data());

    std::vector<vex::command_queue> q1(1, ctx.queue(0));
    vex::vector<real> x(q1, X);
    vex::vector<real> y(q1, Y);

    // Get timings.
    y += A * x;
    y = 0;

    prof.tic_cpu("OpenCL");
    for(size_t i = 0; i < M; i++)
        y += A * x;
    ctx.finish();
    time_elapsed = prof.toc("OpenCL");

    double gflops = (2.0 * nnz + N) * M / time_elapsed / 1e9;
    double bwidth = M * (nnz * (2 * sizeof(real) + sizeof(int)) + 4 * N * sizeof(real)) / time_elapsed / 1e9;

    std::cout
        << "SpMV (CCSR) (" << vex::type_name<real>() << ")\n"
        << "  OpenCL"
        << "\n    GFLOPS:    " << gflops
        << "\n    Bandwidth: " << bwidth
        << std::endl;

    if (options.bm_cpu) {
        prof.tic_cpu("C++");
        for(size_t k = 0; k < M; k++)
            for(size_t i = 0; i < N; i++) {
                real s = 0;
                for(size_t j = row[idx[i]]; j < row[idx[i] + 1]; j++)
                    s += val[j] * X[i + col[j]];
//.........这里部分代码省略.........
开发者ID:sd-omkar,项目名称:hpc_benchmarks,代码行数:101,代码来源:vector.cpp

示例12: row

 Vector4T<T>&       operator[](int i)      { return row(i); }
开发者ID:enuuros,项目名称:multitude,代码行数:1,代码来源:Matrix4.hpp

示例13: name_col

OP_STATUS ExtensionsManagerListViewItem::ConstructItemWidget(QuickWidget** widget)
{
	*widget = NULL;

	// name_col

	OpAutoPtr<QuickStackLayout> name_col(
			OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
	RETURN_OOM_IF_NULL(name_col.get());

	name_col->SetPreferredWidth(WidgetSizes::Fill);
	name_col->SetMinimumWidth(EXTENSION_NAME_MINIMUM_WIDTH);
	m_extension_name = ConstructName();
	RETURN_OOM_IF_NULL(m_extension_name);
	RETURN_IF_ERROR(name_col->InsertWidget(m_extension_name));
	m_author_version = ConstructAuthorAndVersion();
	RETURN_OOM_IF_NULL(m_author_version);
	RETURN_IF_ERROR(name_col->InsertWidget(m_author_version));

	// name_and_buttons_row

	OpAutoPtr<QuickStackLayout> name_and_buttons_row(
			OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL)));
	RETURN_OOM_IF_NULL(name_and_buttons_row.get());

	RETURN_IF_ERROR(name_and_buttons_row->InsertWidget(name_col.release()));
	QuickStackLayout* control_buttons = ConstructControlButtons();
	RETURN_OOM_IF_NULL(control_buttons);
	RETURN_IF_ERROR(name_and_buttons_row->InsertWidget(control_buttons));

	// main_col

	OpAutoPtr<QuickStackLayout> main_col(
			OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
	RETURN_OOM_IF_NULL(main_col.get());

	RETURN_IF_ERROR(main_col->InsertWidget(name_and_buttons_row.release()));
	RETURN_IF_ERROR(main_col->InsertEmptyWidget(0, TEXT_SPACING, 0, TEXT_SPACING));
	m_description = ConstructDescription();
	RETURN_OOM_IF_NULL(m_description);
	RETURN_IF_ERROR(main_col->InsertWidget(m_description));
	QuickStackLayout* debug_buttons = ConstructDebugButtons();
	if (debug_buttons)
	{
		RETURN_IF_ERROR(main_col->InsertWidget(debug_buttons));
	}

	// row_content

	OpAutoPtr<QuickStackLayout> row_content(
			OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL)));
	RETURN_OOM_IF_NULL(row_content.get());

	RETURN_IF_ERROR(
			row_content->InsertEmptyWidget(EXTENSION_ICON_PADDING, 0, EXTENSION_ICON_PADDING, 0));
	m_icon = ConstructExtensionIcon();
	RETURN_OOM_IF_NULL(m_icon);
	RETURN_IF_ERROR(row_content->InsertWidget(m_icon));
	RETURN_IF_ERROR(
			row_content->InsertEmptyWidget(EXTENSION_ICON_PADDING, 0, EXTENSION_ICON_PADDING, 0));
	RETURN_IF_ERROR(row_content->InsertWidget(main_col.release()));
	if (debug_buttons)
	{
		RETURN_IF_ERROR(row_content->InsertEmptyWidget(2, 0, 2, 0));
	}

	// row

	OpAutoPtr<QuickStackLayout> row(
			OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
	RETURN_OOM_IF_NULL(row.get());

	RETURN_IF_ERROR(row->InsertEmptyWidget(0, ROW_ITEM_TOP_PADDING, 0, 
			ROW_ITEM_TOP_PADDING));
	RETURN_IF_ERROR(row->InsertWidget(row_content.release()));
	RETURN_IF_ERROR(row->InsertEmptyWidget(0, ROW_ITEM_BOTTOM_PADDING, 0, 
			ROW_ITEM_BOTTOM_PADDING));

	QuickSkinElement *quick_skin_element =
			QuickSkinWrap(row.release(), "Extensions Panel List Item Skin");
	RETURN_OOM_IF_NULL(quick_skin_element);

	quick_skin_element->GetOpWidget()->SetAlwaysHoverable(TRUE);

	*widget = quick_skin_element;

	UpdateControlButtonsState();
	SetEnabled(!GetModelItem().IsDisabled());

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:91,代码来源:ExtensionsManagerListView.cpp

示例14: c

const float4x4 float4x4::operator * (const float4x4& b) const
{
#if 1
  // a textbook implementation...
  float4x4 c;
  const float4x4 &a = *this;

  for (int i = 1; i <= 4; ++i)
  {
      for (int k = 1; k <= 4; ++k)
      {
        c(i, k) = a(i, 1) * b(1, k) 
                + a(i, 2) * b(2, k) 
                + a(i, 3) * b(3, k) 
                + a(i, 4) * b(4, k);
      }
  }

  return c;
#else
  // assuredly slow, since row() does a lot of logic...
  return make_matrix(dot(row(0), m.c1), dot(row(0), m.c2), dot(row(0), m.c3), dot(row(0), m.c4),  
		  dot(row(1), m.c1), dot(row(1), m.c2), dot(row(1), m.c3), dot(row(1), m.c4), 
		  dot(row(2), m.c1), dot(row(2), m.c2), dot(row(2), m.c3), dot(row(2), m.c4), 
		  dot(row(3), m.c1), dot(row(3), m.c2), dot(row(3), m.c3), dot(row(3), m.c4));
#endif
}
开发者ID:Centril,项目名称:TDA361-Computer-Graphics,代码行数:27,代码来源:float4x4.cpp

示例15: SaveBitmapToFile

void SaveBitmapToFile( const char * fname, LVGrayDrawBuf * bmp )
{
    if (!bmp)
        return;
    LVStreamRef stream = LVOpenFileStream(fname, LVOM_WRITE);
    if (!stream)
        return;
    int rowsize = ((bmp->GetWidth()+1)/2);
    int img_size = rowsize * bmp->GetHeight();
    int padding = rowsize - rowsize;
    BITMAPFILEHEADER fh;
    struct {
        BITMAPINFOHEADER hdr;
        RGBQUAD colors[16];
    } bmi;
    memset(&fh, 0, sizeof(fh));
    memset(&bmi, 0, sizeof(bmi));
    fh.bfType = 0x4D42;
    fh.bfSize = sizeof(fh) + sizeof(bmi) + img_size;
    fh.bfOffBits = sizeof(fh) + sizeof(bmi);
    bmi.hdr.biSize = sizeof(bmi.hdr);
    bmi.hdr.biWidth = bmp->GetWidth();
    bmi.hdr.biHeight = bmp->GetHeight();
    bmi.hdr.biPlanes = 1;
    bmi.hdr.biBitCount = 4;
    bmi.hdr.biCompression = 0;
    bmi.hdr.biSizeImage = img_size;
    bmi.hdr.biXPelsPerMeter = 0xEC4;
    bmi.hdr.biYPelsPerMeter = 0xEC4;
    bmi.hdr.biClrUsed = 16;
    bmi.hdr.biClrImportant = 16;
    static lUInt8 gray[8] = { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xAA, 0x55, 0x00 };
    lUInt8 * pal = bmp->GetBitsPerPixel()==1?gray+0:gray+4;
    for (int i=0; i<4; i++)
    {
        bmi.colors[i].rgbBlue = pal[i];
        bmi.colors[i].rgbGreen = pal[i];
        bmi.colors[i].rgbRed = pal[i];
    }
    stream->Write( &fh, sizeof(fh), NULL );
    stream->Write( &bmi, sizeof(bmi), NULL );
    static const lUInt8 dummy[3] = {0,0,0};
    for (int y=0; y<bmp->GetHeight(); y++)
    {
        LVArray<lUInt8> row( (bmp->GetWidth()+1)/2, 0 );
        for ( int x=0; x<bmp->GetWidth(); x++)
        {
            int cl = bmp->GetPixel(x, bmp->GetHeight()-1-y);
            //int cl = (src[x/8] >> ((1-(x&3))*2)) & 3;
            row[x/2] = row[x/2] | (cl << ((x&1)?0:4));
        }
        row[0] = 0x11;
        row[1] = 0x11;
        row[2] = 0x22;
        row[3] = 0x22;
        row[4] = 0x33;
        row[5] = 0x33;
        *stream << row;
        if (padding)
            stream->Write( dummy, padding, NULL );
    }
}
开发者ID:thiensuhack,项目名称:TestCR,代码行数:62,代码来源:w32utils.cpp


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