su3vec* SpinorStaggeredfieldCreator::createSpinorfield(SpinorFillType fillTypeIn) { su3vec* in; in = new su3vec[numberOfElements]; switch (fillTypeIn) { case SpinorFillType::zero: fill_with_zero(in, numberOfElements); break; case SpinorFillType::one: fill_with_one(in, numberOfElements); break; case SpinorFillType::ascendingReal: fill_with_ascending(in, numberOfElements); break; case SpinorFillType::ascendingComplex: fillWithAscendingComplex(in, numberOfElements); break; default: logger.fatal() << "do not know fill type!"; } BOOST_REQUIRE(in); return in; }
char *add_big_int(char *num_a, char *num_b, char *result) { int i, max_len; int step; /* min_len = min_i(strlen(num_a), strlen(num_b)); */ max_len = max_i(strlen(num_a), strlen(num_b)); /* if(strlen(num_a) > strlen(num_b)) { */ /* long_num = num_a; */ /* short_num = num_b; */ /* } else { */ /* long_num = num_b; */ /* short_num = num_a; */ /* } */ reverse(num_a); reverse(num_b); fill_with_zero(num_a, num_b, max_len); step = 0; for(i = 0; i < max_len; ++i) { step = add_char(num_a[i], num_b[i], result + i, step); } if(step == 1) { result[i++] = step + '0'; } result[i] = 0; /* for each char a in num_a and b in num_b: */ /* c_i != 0 */ /* result[c_i] = a + b + result[c_i-1] - 10 */ /* result[c_i-1] -= 10 */ /* c_i++ */ return reverse(result); }