precision

Precision when reading image with CLK_FILTER_LINEAR in OpenCL

守給你的承諾、 提交于 2019-12-21 20:09:58
问题 The code I used is from this question OpenCL image3d linear sampling , I've tested in 2d and 3d, both with huge diff between CPU and GPU. Here is the result of CPU: coordinate:0.000000, result: 0.000000 coordinate:0.100000, result: 0.000000 coordinate:0.200000, result: 0.000000 coordinate:0.300000, result: 10.156250 coordinate:0.400000, result: 30.078125 coordinate:0.500000, result: 50.000000 coordinate:0.600000, result: 69.921875 coordinate:0.700000, result: 89.843750 coordinate:0.800000,

BigDecimal precision not persisted with JPA annotations

你说的曾经没有我的故事 提交于 2019-12-21 10:34:48
问题 I am using the javax.persistence API and Hibernate to create annotations and persist entities and their attributes in an Oracle 11g Express database. I have the following attribute in an entity: @Column(precision = 12, scale = 9) private BigDecimal weightedScore; The goal is to persist a decimal value with a maximum of 12 digits and a maximum of 9 of those digits to the right of the decimal place. After calculating weightedScore , the result is 0.1234, but once I commit the entity with the

BigDecimal precision not persisted with JPA annotations

时间秒杀一切 提交于 2019-12-21 10:34:42
问题 I am using the javax.persistence API and Hibernate to create annotations and persist entities and their attributes in an Oracle 11g Express database. I have the following attribute in an entity: @Column(precision = 12, scale = 9) private BigDecimal weightedScore; The goal is to persist a decimal value with a maximum of 12 digits and a maximum of 9 of those digits to the right of the decimal place. After calculating weightedScore , the result is 0.1234, but once I commit the entity with the

Why is this bearing calculation so inacurate?

和自甴很熟 提交于 2019-12-21 08:22:00
问题 Is it even that inaccurate? I re-implented the whole thing with Apfloat arbitrary precision and it made no difference which I should have known to start with!! public static double bearing(LatLng latLng1, LatLng latLng2) { double deltaLong = toRadians(latLng2.longitude - latLng1.longitude); double lat1 = toRadians(latLng1.latitude); double lat2 = toRadians(latLng2.latitude); double y = sin(deltaLong) * cos(lat2); double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(deltaLong);

Calculate Mandelbrot set for greater precision

回眸只為那壹抹淺笑 提交于 2019-12-21 05:35:17
问题 Is there any practical way to perform calculations such as those involved in generating the Mandelbrot Set for values for precise that what double or long double can provide? I was thinking of possibly having two variables(either double or long), one storing the value similar to scientific notation and the other storing the negative log10 of the value, but I'm not sure if there would actually be a way to perform the calculation like this. 来源: https://stackoverflow.com/questions/43118611

Using math.isclose function with values close to 0

拜拜、爱过 提交于 2019-12-21 03:52:09
问题 As we know, due to the binary representation of numbers, this expression evaluates to False (at least in Python): 0.2 + 0.4 == 0.6 In order to be able to check for equality within numerical errors, the module math offers isclose : import math math.isclose(0.2 + 0.4 , 0.6) This last expression yields True as expected. Now why does this following expression is False again? math.isclose(0.2 + 0.4 - 0.6 , 0.0) It appears that everything compared to 0.0 is False math.isclose(1.0e-100 , 0.0) 回答1:

Truncate a floating point number without rounding up

拟墨画扇 提交于 2019-12-21 03:28:21
问题 I have a floating point number that I want to truncate to 3 places but I don't want to round up. For example, convert 1.0155555555555555 to 1.015 (not 1.016 ). How would I go about doing this in Ruby? 回答1: Assuming you have a float , try this: (x * 1000).floor / 1000.0 Result: 1.015 See it working online: ideone 回答2: You can also convert to a BigDecimal, and call truncate on it. 1.237.to_d.truncate(2).to_f # will return 1.23 回答3: Since ruby 2.4 Float#truncate method takes as an optional

float and double datatype is good to store latitude and longitude? [duplicate]

别来无恙 提交于 2019-12-20 19:43:25
问题 This question already has answers here : What is the ideal data type to use when storing latitude / longitude in a MySQL database? (21 answers) Closed 4 years ago . I am storing latitude and longitude at the server side (JAVA Platform). To store those values, I am using float and double datatype at the server side. I came to know that float and double are not a recommended primitive datatypes (which is not recommended to use currencies in professional way), because float and double having

2.9999999999999999 >> .5?

被刻印的时光 ゝ 提交于 2019-12-20 18:26:14
问题 I heard that you could right-shift a number by .5 instead of using Math.floor(). I decided to check its limits to make sure that it was a suitable replacement, so I checked the following values and got the following results in Google Chrome: 2.5 >> .5 == 2; 2.9999 >> .5 == 2; 2.999999999999999 >> .5 == 2; // 15 9s 2.9999999999999999 >> .5 == 3; // 16 9s After some fiddling, I found out that the highest possible value of two which, when right-shifted by .5, would yield 2 is 2

What is the most accurate method in python for computing the minimum norm solution or the solution obtained from the pseudo-inverse?

筅森魡賤 提交于 2019-12-20 17:42:33
问题 My goal is to solve: Kc=y with the pseudo-inverse (i.e. minimum norm solution ): c=K^{+}y such that the model is (hopefully) high degree polynomial model f(x) = sum_i c_i x^i . I am specially interested in the underdetermined case where we have more polynomial features than data (few equation too many variables/unknowns) columns = deg+1 > N = rows . Note K is the vandermode matrix of polynomial features. I was initially using the python function np.linalg.pinv but then I noticed something