예제 #1
0
파일: direct.c 프로젝트: naoyam/tapas
// 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)));
    }
}
예제 #2
0
파일: linear.c 프로젝트: rpmsousa/humanoid
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);
	}
}
예제 #3
0
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;
}
예제 #4
0
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);
}
예제 #5
0
파일: v3.cpp 프로젝트: suBDavis/raster
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));
}
예제 #6
0
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);
}
예제 #7
0
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;
}
예제 #8
0
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;
}
예제 #9
0
파일: rijndael.c 프로젝트: DatMatt/dop-mii
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;
}
/*列混合的逆变换*/
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;
}
예제 #11
0
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;
}
예제 #12
0
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]);
    }
}
예제 #13
0
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;
}
 /**
  * @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;
 }
예제 #15
0
파일: umatrix.hpp 프로젝트: cwang218/CPP
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;
}
예제 #16
0
파일: common.c 프로젝트: chemecse/piglit
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;
}
 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;
 }
예제 #18
0
int main(int argc, char const *argv[])
{
  int pro;
  pro=product(5,1,2,3,4,5);
  printf("%d\n",pro );
  return 0;
}
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;
}
예제 #20
0
파일: pipe.c 프로젝트: Jeff-Yu/fju
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;
}
예제 #21
0
void product(int choices, int repeat, int*& arr, int level) {

	int len = pow(choices, repeat);

	if(level == 0) {
		arr = new int[len * repeat];
	}

	int mod = pow(choices, level);

	for(int a = 0; a < len; a++) {
		int b = (a - (a % mod))/mod % choices;
		//printf("%i ", b);
		arr[a*repeat + level] = b;
	}
	//printf("\n");

	if(level < (repeat-1)) {
		product(choices, repeat, arr, level + 1);
	}

	/*
	   if(level == 0) {
	   for(int a = 0; a < len; a++) {
	   for(int b = 0; b < repeat; b++) {
	   printf("%i ",arr[a*repeat + b]);
	   }
	   printf("\n");
	   }
	   }
	   */
}
int main() {
	int t, n, m;
	matrix A, B, F;

	A.a1 = 1; A.a2 = 1; A.a3 = 1; A.a4 = 0;
	F.a1 = 6; F.a2 = 4; F.a3 = 4; F.a4 = 2;
	LL delta;

	scanf("%d", &t);

	while(t--) {
        scanf("%d", &n);
        scanf("%d", &m);

		if(n == 0) {
			printf("0\n");
			continue;
		} else if(n == 1) {
			printf("1\n");
			continue;
		}

		B = get_exp(A, n-1, m);
		B = product(B, F, m);
		delta = ((n+2) / m + 1) * m;
		printf("%lld\n", (B.a2 + delta-n-2) % m);
	}

	return 0;
}
예제 #23
0
    string multiply(string num1, string num2) {
        int i, j;
        int m = num1.size(), n = num2.size();
        // max (m + n) digits
        vector<int> product(m + n, 0);
        string result;

        // reverse for ease of calc
        reverse(num1.begin(), num1.end());
        reverse(num2.begin(), num2.end());

        // digit i * digit j contributes to digit i + j
        for (i = 0; i < m; i++) {
            for (j = 0; j < n; j++) {
                product[i + j] += (num1[i] - '0') * (num2[j] - '0');
                product[i + j + 1] += product[i + j] / 10;
                product[i + j] %= 10;
            }
        }

        // remove leading 0; keep last 0 if all 0
        for (i = m + n - 1; i > 0 && 0 == product[i]; i--)
            ;

        for (; i >= 0; i--)
            result += to_string(product[i]);

        return result;
    }
예제 #24
0
void vctDeterminantTest::TestDeterminant2x2ByInverse(const vctFixedSizeMatrix<ElementType, 2, 2> & inputMatrix)
{
    const ElementType determinant = vctDeterminant<2>::Compute(inputMatrix);

    const ElementType tolerance = cmnTypeTraits<ElementType>::Tolerance();

    if (fabs(determinant) < tolerance) {
        vctFixedSizeVector<ElementType, 2> rowRatio;
        rowRatio.ElementwiseRatioOf( inputMatrix.Row(0), inputMatrix.Row(1) );
        CPPUNIT_ASSERT_DOUBLES_EQUAL( rowRatio[0], rowRatio[1], tolerance );

        vctFixedSizeVector<ElementType, 2> columnRatio;
        columnRatio.ElementwiseRatioOf( inputMatrix.Column(0), inputMatrix.Column(1) );
        CPPUNIT_ASSERT_DOUBLES_EQUAL( columnRatio[0], columnRatio[1], tolerance );

        return;
    }

    const vctFixedSizeMatrix<ElementType, 2, 2> inverse(
        inputMatrix[1][1] / determinant, -inputMatrix[0][1] / determinant,
        -inputMatrix[1][0] / determinant, inputMatrix[0][0] / determinant
        );

    /* gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 crashes with internal error
       on ubuntu 64 - Ubuntu 10.04.1 LTS with const */
    /* const */ vctFixedSizeMatrix<ElementType, 2, 2> product( inputMatrix * inverse );
    const vctFixedSizeMatrix<ElementType, 2, 2> identity( ElementType(1), ElementType(0), ElementType(0), ElementType(1) );
    const vctFixedSizeMatrix<ElementType, 2, 2> difference = product - identity;
    ElementType diffNorm = difference.Norm();
    CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, diffNorm, tolerance );
}
      inline field_polynomial& field_polynomial::operator*=(const field_polynomial& polynomial)
      {
         if (field_ == polynomial.field_)
         {
            field_polynomial product(field_,deg() + polynomial.deg() + 1);

            poly_iter result_it = product.poly_.begin();

            for (poly_iter it0 = poly_.begin(); it0 != poly_.end(); ++it0)
            {
               poly_iter current_result_it = result_it;

               for (const_poly_iter it1 = polynomial.poly_.begin(); it1 != polynomial.poly_.end(); ++it1)
               {
                  (*current_result_it) += (*it0) * (*it1);
                  ++current_result_it;
               }

               ++result_it;
            }

            simplify(product);
            poly_ = product.poly_;
         }

         return *this;
      }
예제 #26
0
Fraction Fraction::operator*(const Fraction &arg)
{
  Fraction product(_numerator * arg._numerator,
                   _denominator * arg._denominator);
  cancel(product);
  return product;
}
예제 #27
0
bigInt multiplyBigInt(bigInt a, bigInt b){
	bigInt product("0");
	bigInt greater("0");
	bigInt lesser("0");

	if (b.num.size() > a.num.size()){						// Find vector with most elements
		greater = b;
		lesser = a;
	}
	else{
		greater = a;
		lesser = b;
	}
	product.num.resize(a.num.size() + b.num.size());		// Get the magnitude of the product 
	product.bigIntInit();
	int k = 0;
	for (unsigned long i = 0; i < lesser.num.size(); i++){					// By hand style multiplacation
		for (unsigned long j = 0; j < greater.num.size(); j++){
			product.num[j + k] += greater.num[j] * lesser.num[i];
		}
		k++;
	}
	product.cleanCarries();
	if (a.isNegative != b.isNegative){
		product.isNegative = 1;
	}
	return product;
}
예제 #28
0
파일: max-size.c 프로젝트: Jul13t/piglit
static bool
is_test_reasonable(bool quick, const struct image_extent size)
{
        /* Set an arbitrary limit on the number of texels so the test
         * doesn't take forever. */
        return product(size) < (quick ? 4 : 64) * 1024 * 1024;
}
예제 #29
0
파일: linear.c 프로젝트: rpmsousa/humanoid
void invert_mat4(mat4 *m, mat4 *n)
{
	scalar d = det(m);

	if (d == (scalar)0.0)
		return;

	/* Cofactor matrix */
	(*n)[0] =   _det_mat3((*m)[5], (*m)[6], (*m)[7], (*m)[9], (*m)[10], (*m)[11], (*m)[13], (*m)[14], (*m)[15]);
	(*n)[1] = - _det_mat3((*m)[1], (*m)[2], (*m)[3], (*m)[9], (*m)[10], (*m)[11], (*m)[13], (*m)[14], (*m)[15]);
	(*n)[2] =   _det_mat3((*m)[1], (*m)[2], (*m)[3], (*m)[5], (*m)[6],  (*m)[7],  (*m)[13], (*m)[14], (*m)[15]);
	(*n)[3] = - _det_mat3((*m)[1], (*m)[2], (*m)[3], (*m)[5], (*m)[6],  (*m)[7],  (*m)[9],  (*m)[10], (*m)[11]);

	(*n)[4] = - _det_mat3((*m)[4], (*m)[6], (*m)[7], (*m)[8], (*m)[10], (*m)[11], (*m)[12], (*m)[14], (*m)[15]);
	(*n)[5] =   _det_mat3((*m)[0], (*m)[2], (*m)[3], (*m)[8], (*m)[10], (*m)[11], (*m)[12], (*m)[14], (*m)[15]);
	(*n)[6] = - _det_mat3((*m)[0], (*m)[2], (*m)[3], (*m)[4], (*m)[6],  (*m)[7],  (*m)[12], (*m)[14], (*m)[15]);
	(*n)[7] =   _det_mat3((*m)[0], (*m)[2], (*m)[3], (*m)[4], (*m)[6],  (*m)[7],  (*m)[8],  (*m)[10], (*m)[11]);

	(*n)[8]  =   _det_mat3((*m)[4], (*m)[5], (*m)[7], (*m)[8], (*m)[9], (*m)[11], (*m)[12], (*m)[13], (*m)[15]);
	(*n)[9]  = - _det_mat3((*m)[0], (*m)[1], (*m)[3], (*m)[8], (*m)[9], (*m)[11], (*m)[12], (*m)[13], (*m)[15]);
	(*n)[10] =   _det_mat3((*m)[0], (*m)[1], (*m)[3], (*m)[4], (*m)[5],  (*m)[7], (*m)[12], (*m)[13], (*m)[15]);
	(*n)[11] = - _det_mat3((*m)[0], (*m)[1], (*m)[3], (*m)[4], (*m)[5],  (*m)[7], (*m)[8],  (*m)[9], (*m)[11]);

	(*n)[12] = - _det_mat3((*m)[4], (*m)[5], (*m)[6], (*m)[8], (*m)[9], (*m)[10], (*m)[12], (*m)[13], (*m)[14]);
	(*n)[13] =   _det_mat3((*m)[0], (*m)[1], (*m)[2], (*m)[8], (*m)[9], (*m)[10], (*m)[12], (*m)[13], (*m)[14]);
	(*n)[14] = - _det_mat3((*m)[0], (*m)[1], (*m)[2], (*m)[4], (*m)[5],  (*m)[6], (*m)[12], (*m)[13], (*m)[14]);
	(*n)[15] =   _det_mat3((*m)[0], (*m)[1], (*m)[2], (*m)[4], (*m)[5],  (*m)[6], (*m)[8],  (*m)[9], (*m)[10]);

	if (d != (scalar)1.0) {
		d = ((scalar)1.0)/d;
		product(&d, n, n);
	}
}
예제 #30
0
파일: secuencial.c 프로젝트: jonatan6/hpc
int main(){

  //double **x = malloc(a * sizeof *x + (a * (b * sizeof **x)));
  //double **y = malloc(b * sizeof *y + (b * (c * sizeof **y)));
  //double **z = malloc(a * sizeof *z + (a * (c * sizeof **z)));

  int size1 = a*b*sizeof(double);
  int size2 = b*c*sizeof(double);
  int size3 = a*c*sizeof(double);

  double *x = (double*)malloc(size1);
  double *y = (double*)malloc(size2);
  double *z = (double*)malloc(size3);

  fillMatrix(x,a,b);
  fillMatrix(y,b,c);

  clock_t begin, end;
  double time_spent;
  begin = clock();

  product(x,y,z);

  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  printf("%lf\n", time_spent);

  //print(z,a,c);

  //print(z,a,c);

}