multiplication

Fastest way to multiply an array of int64_t?

孤者浪人 提交于 2019-12-17 09:37:10
问题 I want to vectorize the multiplication of two memory aligned arrays. I didn't find any way to multiply 64*64 bit in AVX/AVX2, so I just did loop-unroll and AVX2 loads/stores. Is there a faster way to do this? Note: I don't want to save the high-half result of each multiplication. void multiply_vex(long *Gi_vec, long q, long *Gj_vec){ int i; __m256i data_j, data_i; __uint64_t *ptr_J = (__uint64_t*)&data_j; __uint64_t *ptr_I = (__uint64_t*)&data_i; for (i=0; i<BASE_VEX_STOP; i+=4) { data_i =

Java precision during division and multiplication alterneting process [duplicate]

左心房为你撑大大i 提交于 2019-12-13 22:03:55
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How to resolve a Java Rounding Double issue Please Help, I programm some calculator in Java. I use double type. Double has 15 digits after the decimal point. I have problem with the following: 1/3 * 3 = 0.9999999999999999 I need 1/3 * 3 = 1 How can I solve this problem? I keep result in Double. The same problem I have with other mathematical operations, for example sqrt(6) = 2.449489742783, and next I square the

modified baugh-wooley algorithm multiply verilog code does not multiply correctly

天涯浪子 提交于 2019-12-13 17:59:14
问题 The following verilog source code and/or testbench works nicely across commercial simulators, iverilog as well as formal verification tool (yosys-smtbmc) Please keep the complaint about `ifdef FORMAL until later. I need them to use with yosys-smtbmc which does not support bind command yet. I am now debugging the generate coding since the multiplication (using modified baugh-wooley algorithm) does not work yet. When o_valid is asserted, the multiply code should give o_p = i_a * i_b = 3*2 = 6

C# How do basic operation time vary with the size of the numbers?

戏子无情 提交于 2019-12-13 10:29:16
问题 Context of this is a function, which needs to run pretty much once per frame, and is therefore very critical performance-wise. This function contains a loop, and operations inside it. private int MyFunction(int number) { // Code for (int i = 0; i <= 10000; i++) { var value = i * number var valuePow2 = value * value; // Some code which uses valuePow2 several times } return 0; // Not actual line } Now, because of mathematical properties, we know that (a * b)² is equal to a² * b² So, it would be

how to do multiply-all function in RACKET

做~自己de王妃 提交于 2019-12-13 09:48:27
问题 Exercise 22.5.11 Develop a function multiply-all that takes in a list of numbers and returns the result of multiplying them all together. For example: (check-expect (multiply-all (cons 3 (cons 5 (cons 4 empty)))) 60) Hint: What is the “right answer” for the empty list? It may not be what you think at first! Solution: The data definition is similar to that for list-of-strings: ; A list-of-numbers is either ; empty or ; a nelon (non-empty list of numbers). #| (define (function-on-lon L) ; L a

Multiplying Large Number in java

懵懂的女人 提交于 2019-12-13 06:35:49
问题 I am multiplying the 2 very large number in java , but the multiply output seems to be little strange Code long a = 2539586720l; long b = 77284752003l; a*=b; System.out.println(a); a=(long)1e12; b=(long)1e12; a*=b; System.out.println(a); Output: -6642854965492867616 2003764205206896640 In the first case why the result is negative , if it's because of overflow then how come the result of second is positive ? Please explain this behavior ? Code Edit: I am using mod=100000000009 operation still

triggers to multiply 'trigger-based columns' in mysql

最后都变了- 提交于 2019-12-13 04:30:42
问题 I have asked this question before and I want to elaborate it. Triggers to connect multiple tables I have the following trigger (kind of like the one I asked before): CREATE TRIGGER trigger_test1 BEFORE INSERT ON test1 FOR EACH ROW SET NEW.OriginIndex = (SELECT index1 FROM cities WHERE city = NEW.Origin), NEW.DestinationIndex = (SELECT index1 FROM cities WHERE city =NEW.Destination); This part works well. Now I want to multiply OriginIndex and DestinationIndex and store it in another column

An exception on OpenCV matrix Function

。_饼干妹妹 提交于 2019-12-13 03:55:41
问题 I am quite a newbie on OpenCV, and I am just about finished my first big program with it. Actually, I would be if a nasty exception wasn't happening. Here it is: OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupport ed array type) in unknown function, file ........\ocv\opencv\src\cxcore\cxarr ay.cpp, line 2476 And here is the line in which the exception happens: cvMatMul(&matIntrinsec, &matExtrinsec, &result); It might also be important for the topic to know what

Multiply Integers Inside A String By An Individual Value Using Regex

倾然丶 夕夏残阳落幕 提交于 2019-12-13 03:36:35
问题 I currently have the code below and it successfully returns all the numbers that are present in a string I have. An example of the string would be say: 1 egg, 2 rashers of bacon, 3 potatoes. Pattern intsOnly = Pattern.compile("\\d+"); Matcher matcher = intsOnly.matcher(o1.getIngredients()); while (matcher.find()) { Toast.makeText(this, "" + matcher.group(), Toast.LENGTH_LONG).show(); } However, I would like to multiply these numbers by say four and then place them back in the original string.

What does the method prod() do in this Java program?

a 夏天 提交于 2019-12-13 02:27:36
问题 public class Prod { public static void main(String[] args) { System.out.println(prod(1, 4)); } public static int prod(int m, int n) { if (m == n) { return n; } else { int recurse = prod(m, n-1); int result = n * recurse; return result; } } } This is an exercise in the book I am stumped on. Why would the program not just recurse until the two numbers are equal and then return n ? Also, where it says, int result = n * recurse; How does it multiply int n by recurse which would be (int, int) ?