simplify

Expression templates: improving performance in evaluating expressions?

寵の児 提交于 2019-12-01 05:30:01
By the expression templates technique, a matrix expression like D = A*B+sin(C)+3.; is pretty much equivalent, in terms of computing performance, to a hand-written for loop. Now, suppose that I have the following two expressions D = A*B+sin(C)+3.; F = D*E; cout << F << "\n"; In a "classical" implementation by expression templates, the computing performance will be pretty much the same as that of two for loops in sequence. This is because the expressions are evaluated immediately after the = operators are encountered. My question is: is there any technique (for example, using placeholders?) to

Simplify replacement of date object with “today” and “yesterday” strings in Java static method

删除回忆录丶 提交于 2019-11-30 09:02:45
I have following method that I would like to make shorter or faster if nothing else. Please all comments are welcome: Bellow method takes a date object, formates it ("EEE hh:mma MMM d, yyyy") and then figures out if the date is today or yesterday and than, if it is, it returns "(Yesterday | Today) hh:mma" formated string. public static String formatToYesterdayOrToday(String date) { SimpleDateFormat sdf = new SimpleDateFormat("EEE hh:mma MMM d, yyyy"); Date in = null; try { in = sdf.parse(date); } catch (ParseException e) { log.debug("Date parsing error:", e); } Calendar x = Calendar

Simplify replacement of date object with “today” and “yesterday” strings in Java static method

旧街凉风 提交于 2019-11-29 13:08:13
问题 I have following method that I would like to make shorter or faster if nothing else. Please all comments are welcome: Bellow method takes a date object, formates it ("EEE hh:mma MMM d, yyyy") and then figures out if the date is today or yesterday and than, if it is, it returns "(Yesterday | Today) hh:mma" formated string. public static String formatToYesterdayOrToday(String date) { SimpleDateFormat sdf = new SimpleDateFormat("EEE hh:mma MMM d, yyyy"); Date in = null; try { in = sdf.parse(date

Simplification / optimization of GPS track

陌路散爱 提交于 2019-11-28 18:03:49
I've got a GPS track produced by gpxlogger(1) (supplied as a client for gpsd ). GPS receiver updates its coordinates every 1 second, gpxlogger's logic is very simple, it writes down location ( lat , lon , ele ) and a timestamp ( time ) received from GPS every n seconds ( n = 3 in my case). After writing down a several hours worth of track, gpxlogger saves several megabyte long GPX file that includes several thousands of points. Afterwards, I try to plot this track on a map and use it with OpenLayers . It works, but several thousands of points make using the map a sloppy and slow experience. I

Simplification / optimization of GPS track

强颜欢笑 提交于 2019-11-27 11:01:09
问题 I've got a GPS track produced by gpxlogger(1) (supplied as a client for gpsd). GPS receiver updates its coordinates every 1 second, gpxlogger's logic is very simple, it writes down location ( lat , lon , ele ) and a timestamp ( time ) received from GPS every n seconds ( n = 3 in my case). After writing down a several hours worth of track, gpxlogger saves several megabyte long GPX file that includes several thousands of points. Afterwards, I try to plot this track on a map and use it with

Strategies for simplifying math expressions

走远了吗. 提交于 2019-11-26 21:29:29
I have a well-formed tree that represents a mathematical expression. For example, given the string: "1+2-3*4/5" , this gets parsed into: subtract(add(1,2),divide(multiply(3,4),5)) Which is expressed as this tree: What I'd like to be able to do is take this tree and reduce it as much as possible. In the case above, this is pretty simple, because all of the numbers are constants. However, things start to get trickier once I allow for unknowns (denoted with a $ followed by an identifier): "3*$a/$a" becomes divide(multiply(3,$a), $a) This should simplify to 3 , since the $a terms should cancel

Strategies for simplifying math expressions

寵の児 提交于 2019-11-26 06:59:55
问题 I have a well-formed tree that represents a mathematical expression. For example, given the string: \"1+2-3*4/5\" , this gets parsed into: subtract(add(1,2),divide(multiply(3,4),5)) Which is expressed as this tree: What I\'d like to be able to do is take this tree and reduce it as much as possible. In the case above, this is pretty simple, because all of the numbers are constants. However, things start to get trickier once I allow for unknowns (denoted with a $ followed by an identifier): \"3