• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ product函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: interact

// only c1 and c2 can be modified
static void interact(const struct cell *c1, const struct cell *c2) {
    if (is_leaf(c1) && is_leaf(c2)) {
        direct(c1, c2);
    } else if (is_leaf(c1)) {
        map(interact, product(c1, get_subcells(c2)));
    } else if (is_leaf(c2)) {
        map(interact, product(get_subcells(c1), c2));
    } else {
        map(interact, product(get_subcells(c1), get_subcells(c2)));
    }
}
开发者ID:naoyam,项目名称:tapas,代码行数:12,代码来源:direct.c


示例2: normalize_vec4

void normalize_vec4(vec4 *v)
{
	scalar n;

	/* normalize v */
	product(v, v, &n);
	if ((n != (scalar) 0.0) && (n != (scalar)1.0)) {
		n = (scalar)1.0 / sqrtf(n);
		product(&n, v, v);
	}
}
开发者ID:rpmsousa,项目名称:humanoid,代码行数:11,代码来源:linear.c


示例3: power

Poly power(Poly P, LL n, const Poly &coef)
{
    Poly ret(P.size());
    ret[0] = 1;
    while (n) {
        if (n & 1) ret = product(ret, P, coef);
        P = product(P, P, coef);
        n >>= 1;
    }
    return ret;
}
开发者ID:neroneroni,项目名称:ACM-ICPC,代码行数:11,代码来源:linear_rec_seq.cpp


示例4: multinomialSamplingProb

long double multinomialSamplingProb(const vector<long double>& probs, const vector<int>& obs) {
    vector<long double> factorials;
    vector<long double> probsPowObs;
    factorials.resize(obs.size());
    transform(obs.begin(), obs.end(), factorials.begin(), factorial);
    vector<long double>::const_iterator p = probs.begin();
    vector<int>::const_iterator o = obs.begin();
    for (; p != probs.end() && o != obs.end(); ++p, ++o) {
        probsPowObs.push_back(pow(*p, *o));
    }
    return factorial(sum(obs)) / product(factorials) * product(probsPowObs);
}
开发者ID:YuankunZhu,项目名称:freebayes,代码行数:12,代码来源:Multinomial.cpp


示例5: v3

v3 v3::transform_4(mat44 t_mat){
    colvec4 operand = {x, y, z, c};
    colvec4 product = t_mat * operand;
//    if (product(3) == -7 && c==1){
//        std::cout << "operand --" << std::endl;
//        operand.print();
//        std::cout << "product --" << std::endl;
//        product.print();
//        std::cout << "t_mat --" <<std::endl;
//        t_mat.print();
//    }
    return v3(product(0), product(1), product(2), product(3));
}
开发者ID:suBDavis,项目名称:raster,代码行数:13,代码来源:v3.cpp


示例6: main

int main(int argc, char *argv[]) {
    FILE* output;
    double a[nmax], b[nmax], c[nmax];
    double sa, sb, sc, max;
    int na, nb, nc;
    int minval, maxval;
    setlocale(LC_ALL, "rus");
//    Проверки на правильность введенных аргументов
    if (argc < 6) {
        fprintf(stderr, "Недостаточно параметров!\n");
        return -1;
    }
    if (!sscanf(argv[1], "%d", &minval)){
        fprintf(stderr, "1-ый и 2-ой аргумент должны представлять минимальную и максимальную границу диапозона, соответственно.\n");
        return -2;
    }
    if (!sscanf(argv[2], "%d", &maxval)){
        fprintf(stderr, "1-ый и 2-ой аргумент должны представлять минимальную и максимальную границу диапозона, соответственно.\n");
        return -3;
    }
    if (minval >= maxval){
        fprintf(stderr, "Пустой диапозон.\n");
        return -4;
    }
    if ((output = fopen(s_output, "w")) == NULL) {
        fprintf(stderr, "Невозможно создать файл '%s'\n", s_output);
        return -5;
    }
//    Вывод диапазона
    fprintf(output, "Диапазон: %d - %d\n", minval, maxval);
//    Ввод массивов из файлов
    if (!ArrayInput(&na, a, argv[3], &fclose))
        return -5;
    if (!ArrayInput(&nb, b, argv[4], &fclose))
        return -6;
    if (!ArrayInput(&nc, c, argv[5], &fclose))
        return -7;
//    Умножение элементов, выходящих за границы
    sa = product(a, na, minval, maxval, &check);
    sb = product(b, nb, minval, maxval, &check);
    sc = product(c, nc, minval, maxval, &check);
//    Поиск максимального значения
    max = sa;
    if (sb > max) max = sb;
    if (sc > max) max = sc;
//    Вывод результатов
    if (sa == max) fprintf(output, "Массив А имеет максимальное произведение элементов: %9.3lf\n", max);
    if (sb == max) fprintf(output, "Массив B имеет максимальное произведение элементов: %9.3lf\n", max);
    if (sc == max) fprintf(output, "Массив C имеет максимальное произведение элементов: %9.3lf\n", max);
}
开发者ID:vdsirotkin,项目名称:10_programs,代码行数:50,代码来源:lab6.cpp


示例7: return

bool Interval::intersect_soft (Interval tmp)
{
    if ((product(tmp.s).sign() == product(tmp.e).sign() && (product(tmp.s)).sign() != 0) ||
		(tmp.product(s).sign() == (tmp.product(e)).sign() && (tmp.product(s)).sign() != 0))
		return false;
	if (product(tmp.s).sign() == product(tmp.e).sign() && (product(tmp.s)).sign() == 0)
	{
		Fraction max1;
		Fraction max2;
		Fraction min1;
		Fraction min2;
		if(s.getX() != e.getX())
		{
			max1 = (s.getX() <= e.getX() ? e.getX() : s.getX());
			max2 = (s.getX() <= e.getX() ? e.getX() : s.getX());
			min1 = (s.getX() <= e.getX() ? s.getX() : e.getX());
			min2 = (s.getX() <= e.getX() ? e.getX() : s.getX());
		}
		else
		{
			max1 = (s.getY() <= e.getY() ? e.getY() : s.getY());
			max2 = (s.getY() <= e.getY() ? e.getY() : s.getY());
			min1 = (s.getY() <= e.getY() ? s.getY() : e.getY());
			min2 = (s.getY() <= e.getY() ? e.getY() : s.getY());
		}
		return (max1 >= min2 && max2 >= min1);
	}
	if(product(tmp.s).sign() != product(tmp.e).sign() && tmp.product(s).sign() != (tmp.product(e)).sign())
		return true;
	return false;
}
开发者ID:nitroman1991,项目名称:Division,代码行数:31,代码来源:subsidiary.cpp


示例8: product

char *sum(void){
	char *var1, *var2;
	var1 = product();
	while(match(PLUS)){
		advance();
		var2 = product();
		//printf("%s = %s + %s\n", var1,var1,var2);
		//printf("ADD %s, %s\n", var2,var1);
        fprintf(f,"ADD %s, %s\n", var2,var1);
		freename(var2);
	}

	return var1;
}
开发者ID:sanketh95,项目名称:compilers,代码行数:14,代码来源:code_gen_new.c


示例9: InvMixCol

static u32 InvMixCol(u32 x) { /* matrix Multiplication */
    u32 y,m;
    u8 b[4];

    m=pack(InCo);
    b[3]=product(m,x);
    m=ROTL24(m);
    b[2]=product(m,x);
    m=ROTL24(m);
    b[1]=product(m,x);
    m=ROTL24(m);
    b[0]=product(m,x);
    y=pack(b);
    return y;
}
开发者ID:DatMatt,项目名称:dop-mii,代码行数:15,代码来源:rijndael.c


示例10: InvMixCol

/*列混合的逆变换*/
static WORD InvMixCol(WORD x)
{ /* matrix Multiplication */
	WORD y,m;
	BYTE b[4];
	m=pack(InCo);
	b[3]=product(m,x);
	m=ROTL24(m);
	b[2]=product(m,x);
	m=ROTL24(m);
	b[1]=product(m,x);
	m=ROTL24(m);
	b[0]=product(m,x);
	y=pack(b);
	return y;
}
开发者ID:RUIXUEZHAOFENGNIAN,项目名称:mycode,代码行数:16,代码来源:AES加解密算法1.cpp


示例11: main

int main()
{
    FILE *in = fopen("ride.in", "r");
    FILE *out = fopen("ride.out", "w");
    
    char comet[LEN], group[LEN];

    fscanf(in, "%s\n%s", comet, group);
    fprintf(out, "%s\n", (product(comet)%47 == product(group)%47) ? "GO" : "STAY");

    fclose(in);
    fclose(out);

    return 0;
}
开发者ID:brunocasteleiro,项目名称:competitive-programming,代码行数:15,代码来源:ride.c


示例12: norm

void CLyapWolfMethod::orthonormalize()
{
  if (mNumExp < 1) return;

  //TODO generalize
  C_FLOAT64 *dbl, *dblEnd;

  dbl = mVariables.array() + mSystemSize;
  dblEnd = dbl + mSystemSize;
  mNorms[0] = norm(dbl, dblEnd);
  scalarmult(dbl, dblEnd, 1 / mNorms[0]);

  size_t i, j;

  for (i = 1; i < mNumExp; ++i)
    {
      dbl += mSystemSize;
      dblEnd = dbl + mSystemSize;

      //orthogonalisation
      for (j = 0; j < i; ++j)
        {
          add(dbl, dblEnd,
              -product(dbl, dblEnd, mVariables.array() + (j + 1)*mSystemSize),
              mVariables.array() + (j + 1)*mSystemSize);
        }

      //normalisation
      mNorms[i] = norm(dbl, dblEnd);
      scalarmult(dbl, dblEnd, 1 / mNorms[i]);
    }
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:32,代码来源:CLyapWolfMethod.cpp


示例13: load_nc_array

template<class T> static bool load_nc_array(const NcFile& ncf, const string& name, vector<T>& dest, bool required = true, int offset = 0, int count = -1)
{
	NcVar *v = load_nc_variable(ncf, name.c_str(), required);
	if (v)
	{
		vector<long> offsets = list_of(offset).repeat(v->num_dims()-1, 0);
		v->set_cur(&offsets.front());
		vector<long> counts (v->num_dims());
		long* shape = v->edges();
		transform(shape, shape + v->num_dims(), offsets.begin(), counts.begin(), minus<long>());
		delete shape;
		if (count > 0)
		{
			counts[0] = count;
		}
		dest.resize(product(counts));
		bool success = v->get(&dest.front(), &counts.front());
		if (!success)
		{
			dest.resize(0);
			check(!required, string("NetcdfDataset::load_nc_array<") + typeid(T).name() + "> " + name + '\n' + "failed with offset " + str(offsets) + ", counts " + str(counts));
		}
		return success;
	}
	return false;
}
开发者ID:tpajenka,项目名称:RNNLIB,代码行数:26,代码来源:NetcdfDataset.hpp


示例14: productExcludeItself

 /**
  * @param A: Given an integers array A
  * @return: A long long array B and B[i]= A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1]
  */
 vector<long long> productExcludeItself(vector<int> &nums) {
     if (nums.size() < 2) {
         return vector<long long>();
     }
     
     vector<long long> left_product(nums.size());
     vector<long long> right_product(nums.size());
     vector<long long> product(nums.size());
     
     left_product[0] = 1;
     for (int i = 1; i < nums.size(); ++i) {
         left_product[i] = left_product[i - 1] * nums[i - 1];
     }
     
     right_product[nums.size() - 1] = 1;
     for (int j = nums.size() - 2; j >= 0; --j) {
         right_product[j] = right_product[j + 1] * nums[j + 1];
     }
     
     for (int k = 0; k < nums.size(); ++k) {
         product[k] = left_product[k] * right_product[k];
     }
     
     return product;
 }
开发者ID:codingwhite,项目名称:LintCode,代码行数:29,代码来源:product-of-array-exclude-itself.cpp


示例15: product

UMatrix<T>& UMatrix<T> :: operator*(const T mult)
{
//		if(m_dimension != source.m_dimension)	throw Exception(5);
		UMatrix<T> product(m_dimension);

		for(int i=0; i<m_dimension; i++)
		{
			for(int j=0; j<m_dimension-i; j++)
			{
				product(i,j) = m_ptr_to_data[i][j] * mult;
			}
		}

		copy(product);
		return *this;
}
开发者ID:cwang218,项目名称:CPP,代码行数:16,代码来源:umatrix.hpp


示例16: init_fb

bool
init_fb(const struct grid_info grid)
{
        bool ret = true;

        if (grid.stages & GL_COMPUTE_SHADER_BIT) {
                const struct image_info img = image_info_for_grid(grid);
                const unsigned n = product(grid.size) *
                        image_num_components(grid.format);
                uint32_t *pixels = malloc(n * sizeof(*pixels));

                ret = init_pixels(img, pixels, 0.5, 0.5, 0.5, 0.5) &&
                        upload_image(img, max_image_units(), pixels);

                free(pixels);
        } else {
                ret = generate_fb(grid, 0);

                glClearColor(0.5, 0.5, 0.5, 0.5);
                glClear(GL_COLOR_BUFFER_BIT);

                glClearDepth(0.5);
                glClear(GL_DEPTH_BUFFER_BIT);
        }

        return ret;
}
开发者ID:chemecse,项目名称:piglit,代码行数:27,代码来源:common.c


示例17: multiply

 vector<vector<int>> multiply(vector<vector<int>>& A, vector<vector<int>>& B) {
     int row1 = A.size();
     int col1 = A[0].size();
     int row2 = B.size();
     int col2 = B[0].size();
     vector<vector<int>> product(row1, vector<int>(col2, 0));
     
     for(int i = 0; i < row1; i++) {
         bool zeroRow = true;
         for(int p = 0; p < col1; ++p) {
             if(A[i][p] != 0) {
                 zeroRow = false;
                 break;
             }
         }
         if(zeroRow) continue;
         for(int j = 0; j < col2; ++j) {
             bool zeroCol = true;
             for(int q = 0; q < row2; ++q) {
                 if(B[q][j] != 0) {
                     zeroCol = false;
                     break;
                 }
             }
             if(zeroCol) continue;
             for(int k = 0; k < col1; ++k) {
                 if(A[i][k] == 0 or B[k][j] == 0) continue;    
                 product[i][j] += (A[i][k] * B[k][j]);
             }
         }
     }
     return product;
 }
开发者ID:Kaidul,项目名称:LeetCode_problems_solution,代码行数:33,代码来源:Sparse_Matrix_Multiplication.cpp


示例18: main

int main(int argc, char const *argv[])
{
  int pro;
  pro=product(5,1,2,3,4,5);
  printf("%d\n",pro );
  return 0;
}
开发者ID:hejiangda,项目名称:C_Program_Test,代码行数:7,代码来源:ex14.2.c


示例19: main

int main()
{
    float a, b, r;
    char op;
    do {
       printf("Extra line of code --- \n");
       printf("Number operator Number: ");

       scanf(" %f %c %f", &a, &op, &b);
       switch (op)
       {
           case '+' : r = add(a,b);
                      break;
           case '*' : r = product(a,b);
                      break;
           case '-' : r = subtract(a,b);
                      break;
           case '/' : r = divide(a,b);
                      break;
           case '%' : r = remainder(a,b);
                      break; 
           case 'q' : break;
           default  : op='?';
       }
       if (op=='?')
          printf("Unknown operator\n");
       else if (op=='q')
          printf("Bye\n");
       else
          printf("%f %c %f = %f\n", a, op, b, r);
    }
    while (op != 'q');
    
    return 0;
}
开发者ID:KishanUnnadkat,项目名称:maths_function,代码行数:35,代码来源:maths_functions.c


示例20: main

int main(int argc, char *argv[]) {
	int fds[2] = {0};
	int th = 0;

	int ret = pipe(fds);
	if (ret < 0) {
		printf("pipe failed\n");
		return -1;
	}

	th = fork();

	if (th < 0) {
		printf("fork failed\n");
		return -1;

	} else if (th == 0) {
		product(fds);
	
	} else {
		consumer(fds);
	
	}

	wait(NULL);

	return 0;
}
开发者ID:Jeff-Yu,项目名称:fju,代码行数:28,代码来源:pipe.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ prof_start函数代码示例发布时间:2022-05-30
下一篇:
C++ prod函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap