multiplication

Multiplying a string by an int in c++

ⅰ亾dé卋堺 提交于 2019-12-18 05:22:33
问题 What do I have to do so that when I string s = "."; If I do cout << s * 2; Will it be the same as cout << ".."; ? 回答1: No, std::string has no operator * . You can add (char, string) to other string. Look at this http://en.cppreference.com/w/cpp/string/basic_string And if you want this behaviour (no advice this) you can use something like this #include <iostream> #include <string> template<typename Char, typename Traits, typename Allocator> std::basic_string<Char, Traits, Allocator> operator *

tinyAVR: best known multiplication routines for 8-bit and 16-bit factors? [closed]

蓝咒 提交于 2019-12-18 05:12:41
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . "Faster than avr200b.asm"? The mpy8u -routine from avr200b.asm for those processors of Atmel's AVR family that do not implement any of the MUL instructions seems pretty generic, but mpy16u looks sloppy for rotating both lower result bytes 16 times instead of 8. Antonio presented a

Strassen's algorithm for matrix multiplication

自闭症网瘾萝莉.ら 提交于 2019-12-17 22:05:39
问题 Can someone please explain strassen's algorithm for matrix multiplication in an intuitive way? I've gone through (well, tried to go through) the explanation in the book and wiki but it's not clicking upstairs. Any links on the web that use a lot of English rather than formal notation etc. would be helpful, too. Are there any analogies which might help me build this algorithm from scratch without having to memorize it? 回答1: Consider multiplying two 2x2 matrices, as follows: A B * E F = AE+BG

Translation from Complex-FFT to Finite-Field-FFT

百般思念 提交于 2019-12-17 20:58:51
问题 Good afternoon! I am trying to develop an NTT algorithm based on the naive recursive FFT implementation I already have. Consider the following code ( coefficients ' length, let it be m , is an exact power of two): /// <summary> /// Calculates the result of the recursive Number Theoretic Transform. /// </summary> /// <param name="coefficients"></param> /// <returns></returns> private static BigInteger[] Recursive_NTT_Skeleton( IList<BigInteger> coefficients, IList<BigInteger> rootsOfUnity, int

long long vs int multiplication

泪湿孤枕 提交于 2019-12-17 19:28:18
问题 Given the following snippet: #include <stdio.h> typedef signed long long int64; typedef signed int int32; typedef signed char int8; int main() { printf("%i\n", sizeof(int8)); printf("%i\n", sizeof(int32)); printf("%i\n", sizeof(int64)); int8 a = 100; int8 b = 100; int32 c = a * b; printf("%i\n", c); int32 d = 1000000000; int32 e = 1000000000; int64 f = d * e; printf("%I64d\n", f); } The output with MinGW GCC 3.4.5 is (-O0): 1 4 8 10000 -1486618624 The first multiplication is casted to an

Could not find an overload for '*' that accepts the supplied argument

家住魔仙堡 提交于 2019-12-17 19:24:01
问题 I have converted a String to an Int by by using toInt() . I then tried multiplying it by 0.01, but I get an error that says Could not find an overload for '*' that accepts the supplied argument. Here is my code: var str: Int = 0 var pennyCount = 0.00 str = pennyTextField.text.toInt()! pennyCount = str * 0.01 From reading other posts it seems that the answer has to do with the type. For example if the type is set as an Integer then it gets a similar error. I have tried changing the type to an

Pandas: Elementwise multiplication of two dataframes

て烟熏妆下的殇ゞ 提交于 2019-12-17 18:28:17
问题 I know how to do element by element multiplication between two Pandas dataframes. However, things get more complicated when the dimensions of the two dataframes are not compatible. For instance below df * df2 is straightforward, but df * df3 is a problem: df = pd.DataFrame({'col1' : [1.0] * 5, 'col2' : [2.0] * 5, 'col3' : [3.0] * 5 }, index = range(1,6),) df2 = pd.DataFrame({'col1' : [10.0] * 5, 'col2' : [100.0] * 5, 'col3' : [1000.0] * 5 }, index = range(1,6),) df3 = pd.DataFrame({'col1' :

Fast multiplication/division by 2 for floats and doubles (C/C++)

落爺英雄遲暮 提交于 2019-12-17 10:58:35
问题 In the software I'm writing, I'm doing millions of multiplication or division by 2 (or powers of 2) of my values. I would really like these values to be int so that I could access the bitshift operators int a = 1; int b = a<<24 However, I cannot, and I have to stick with doubles. My question is : as there is a standard representation of doubles (sign, exponent, mantissa), is there a way to play with the exponent to get fast multiplications/divisions by a power of 2 ? I can even assume that

SSE multiplication of 4 32-bit integers

拜拜、爱过 提交于 2019-12-17 10:54:09
问题 How to multiply four 32-bit integers by another 4 integers? I didn't find any instruction which can do it. 回答1: If you need signed 32x32 bit integer multiplication then the following example at software.intel.com looks like it should do what you want: static inline __m128i muly(const __m128i &a, const __m128i &b) { __m128i tmp1 = _mm_mul_epu32(a,b); /* mul 2,0*/ __m128i tmp2 = _mm_mul_epu32( _mm_srli_si128(a,4), _mm_srli_si128(b,4)); /* mul 3,1 */ return _mm_unpacklo_epi32(_mm_shuffle_epi32

Efficient outer product in python

给你一囗甜甜゛ 提交于 2019-12-17 09:56:08
问题 Outer product in python seems quite slow when we have to deal with vectors of dimension of order 10k. Could someone please give me some idea how could I speed up this operation in python? Code is as follows: In [8]: a.shape Out[8]: (128,) In [9]: b.shape Out[9]: (32000,) In [10]: %timeit np.outer(b,a) 100 loops, best of 3: 15.4 ms per loop Since I have to do this operation several times, my code is getting slower. 回答1: It doesn't really get any faster than that, these are your options: numpy