multiplication

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

孤街浪徒 提交于 2019-11-28 10:09:16
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 Int, but that doesn't seem to solve the problem. I have also tried setting the type for 'str' and

How can I multiply two hex 128 bit numbers in assembly

雨燕双飞 提交于 2019-11-28 08:01:37
问题 I have two 128 bit numbers in memory in hexadecimal, for example (little endian): x:0x12 0x45 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 y:0x36 0xa1 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 I've to perform the unsigned multiplication between these two numbers so my new number will be: z:0xcc 0xe3 0x7e 0x2b 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Now, I'm aware that I can move the half x and y number into rax and rbx

SSE multiplication of 2 64-bit integers

一曲冷凌霜 提交于 2019-11-28 07:36:41
问题 How to multiply two 64-bit integers by another 2 64-bit integers? I didn't find any instruction which can do it. 回答1: I know this is an old question but I was actually looking for exactly this. As there's still no instruction for it I implemented the 64 bit multiply myself with the pmuldq as Paul R mentioned. This is what I came up with: // requires g++ -msse4.1 ... #include <emmintrin.h> #include <smmintrin.h> __m128i Multiply64Bit(__m128i a, __m128i b) { auto ax0_ax1_ay0_ay1 = a; auto bx0

Pandas: Elementwise multiplication of two dataframes

我怕爱的太早我们不能终老 提交于 2019-11-28 07:34:07
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' : [0.1] * 5}, index = range(1,6),) df.mul(df2, 1) # element by element multiplication no problems df.mul

Parallel Matrix Multiplication in Java 6

戏子无情 提交于 2019-11-28 01:18:00
问题 Yesterday I asked a question about parallel matrix multiplication in Java 7 using the fork/join framework here. With the help of axtavt I got my example program to work. Now I’m implementing an equivalent program using Java 6 functionality only. I get the same problem as yesterday, dispite applying the the feedback axtavt gave me (I think). Am I overlooking something? Code: package algorithms; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util

Multiply each element in a vector by itself to create a matrix

梦想与她 提交于 2019-11-28 01:12:23
I'm trying to multiply each element in a vector by itself such that it produces a matrix that is symmetric about the diagonal. For example, given this vector:: x <- 1:3 I would like to create this: 1 2 3 2 4 6 3 6 9 i.e: x[1]*x[1] x[2]*x[1] x[3]*x[1] x[1]*x[2] x[2]*x[2] x[3]*x[2] x[1]*x[3] x[2]*x[3] x[3]*x[3] Any help would be greatly appreciated. Thanks. Like this: x %o% x which is a shortcut for outer(x, x) You can also do tcrossprod(x) 来源: https://stackoverflow.com/questions/22212484/multiply-each-element-in-a-vector-by-itself-to-create-a-matrix

32-bit signed integer multiplication without using 64-bit data type

心不动则不痛 提交于 2019-11-27 22:38:20
I want to do 32-bit signed integer multiplication without using a 64-bit data type. My inputs are in Q1.31 (both) format. input1 = A32 (Ah Al) - higher, lower half's of A32 input2 = B32 (Bh Bl) - higher, lower half's of B32 Result should be in Q1.31 format, leave the overflow case. I need C code. Please provide the explanation with formats also. Signed Q1.31 format is a fully fractional format capable of representing operands between -1 and almost +1. The scale factor is 2 31 . This means that when each Q1.31 operand is stored in a 32-bit signed integer, we can generate the Q1.31 product by

Matrix multiplication with iterator dependency - NumPy

a 夏天 提交于 2019-11-27 22:37:45
问题 Sometime back this question (now deleted but 10K+ rep users can still view it) was posted. It looked interesting to me and I learnt something new there while trying to solve it and I thought that's worth sharing. I would like to post those ideas/solutions and would love to see people post other possible ways to solve it. I am posting the gist of the question next. So, we have two NumPy ndarrays a and b of shapes : a : (m,n,N) b : (n,m,N) Let's assume we are dealing with cases where m , n & N

x86_64: is IMUL faster than 2x SHL + 2x ADD?

混江龙づ霸主 提交于 2019-11-27 19:24:36
问题 When looking at the assembly produced by Visual Studio (2015U2) in /O2 (release) mode I saw that this 'hand-optimized' piece of C code is translated back into a multiplication: int64_t calc(int64_t a) { return (a << 6) + (a << 16) - a; } Assembly: imul rdx,qword ptr [a],1003Fh So I was wondering if that is really faster than doing it the way it is written, something like: mov rbx,qword ptr [a] mov rax,rbx shl rax,6 mov rcx,rbx shl rcx,10h add rax,rcx sub rax,rbx I was always under the

How to perform multiplication, using bitwise operators?

泄露秘密 提交于 2019-11-27 18:01:48
I am working through a problem which i was able to solve, all but for the last piece - i am not sure how can one do multiplication using bitwise operators: 0*8 = 0 1*8 = 8 2*8 = 16 3*8 = 24 4*8 = 32 Can you please recommend an approach to solve this? Preet Sangha To multiply by any value of 2 to the power of N (i.e. 2^N) shift the bits N times to the left. 0000 0001 = 1 times 4 = (2^2 => N = 2) = 2 bit shift : 0000 0100 = 4 times 8 = (2^3 -> N = 3) = 3 bit shift : 0010 0000 = 32 etc.. To divide shift the bits to the right. The bits are whole 1 or 0 - you can't shift by a part of a bit thus if