Jump to content

Wikipedia:Reference desk/Computing

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 71.119.131.184 (talk) at 00:33, 5 February 2016 (→‎SSD, virtual memory, thrashing). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Welcome to the computing section
of the Wikipedia reference desk.
Select a section:
Want a faster answer?

Main page: Help searching Wikipedia

   

How can I get my question answered?

  • Select the section of the desk that best fits the general topic of your question (see the navigation column to the right).
  • Post your question to only one section, providing a short header that gives the topic of your question.
  • Type '~~~~' (that is, four tilde characters) at the end – this signs and dates your contribution so we know who wrote what and when.
  • Don't post personal contact information – it will be removed. Any answers will be provided here.
  • Please be as specific as possible, and include all relevant context – the usefulness of answers may depend on the context.
  • Note:
    • We don't answer (and may remove) questions that require medical diagnosis or legal advice.
    • We don't answer requests for opinions, predictions or debate.
    • We don't do your homework for you, though we'll help you past the stuck point.
    • We don't conduct original research or provide a free source of ideas, but we'll help you find information you need.



How do I answer a question?

Main page: Wikipedia:Reference desk/Guidelines

  • The best answers address the question directly, and back up facts with wikilinks and links to sources. Do not edit others' comments and do not give any medical or legal advice.
See also:


February 1

Recording videos

In Windows 8.1, how can one record on video what's happening on one's own computer screen? Does one need any external devices for this? 2601:646:8E01:9089:F88D:DE34:7772:8E5B (talk) 02:36, 1 February 2016 (UTC)[reply]

It appears that Screencam will do it. See Comparison of screencasting software for more options. Bubba73 You talkin' to me? 02:40, 1 February 2016 (UTC)[reply]
Thanks! 2601:646:8E01:9089:F88D:DE34:7772:8E5B (talk) 03:42, 1 February 2016 (UTC)[reply]
I would hope that at one point there will be a single keyboard button to do this, using a built-in function, just as Screen Print now grabs a single frame. StuRat (talk) 05:28, 1 February 2016 (UTC) [reply]
Probably not in the near future, because not all computers have the needed software. 2601:646:8E01:9089:F88D:DE34:7772:8E5B (talk) 07:41, 1 February 2016 (UTC)[reply]
Windows 10 actually comes with this by default although it's primarily targeted at games. Note that without some support of hardware support, x264 realtime encoding is fairly demanding. Screencam style capturing won't work well if you have something with significant motion but in any case, if you're comparing to screenshots those are normally simple images so video recording is most similar. Nil Einne (talk) 14:11, 2 February 2016 (UTC)[reply]

How frequent brief charging affects phone battery life

I have a Samsung Galaxy S3 and a wonky charger. I think some of the pins might be missing or it's just a fraction too small. Sometimes it will flicker back and forth from charging and not charging, maybe even hundreds of times in a night. I feel like this is frying my battery, by essentially charging it in 1 second intervals dozens of times rather than one consistent charge. I thought I read somewhere that what kills the battery is charging it many times such as this. Detrimental or just tedious? NIRVANA2764 (talk) 03:18, 1 February 2016 (UTC)[reply]

This behaviour may affect the battery since it ideally should be charged with a CC-CV profile which isn't properly possible if it's been disconnected so often. However I would be more concerned about the affect on the phone. It's fairly unlikely it's designed for the charging to be connected and disconnected hundreds of times a day. Worst case you damage something causing the protection mechanism to stop overcharging to fail and risk a fire from the lithium ion battery. This may not be that likely, but I'm not sure how well the phone will have been tested for charging to be disconnected and reconned hundreds of times a day over long period. There's even greater concern if there is indeed an intermited connection. If it's on the phone side you definitely risk damaging something on the phone, permanently. If the intermited connection is on the power plug side, or inside the charger, there is a risk of fire or electric shock. (There's also a possibility the charger won't cope with such frequent disconnections and reconnects causing damage which could cause these or simply an unreliable supply to the phone which may result in the aforementioned possibilities.) I strongly suggest you throw out the charger. If you don't already have another USB charger, I suspect you're not using your phone to type this but a computer of some sort with a USB socket. If I'm correct, I suggest you connect your phone to your computer for charging until you get a new oneUSB charger (or just use your computer all the time). Of course if the problem is with the micro USB cable, you'll need to buy a new one (and perhaps in that case the USB charger itself is fine). Nil Einne (talk) 12:22, 1 February 2016 (UTC)[reply]
"more concerned about the affect on the phone"? Isn't the phone getting enough love? Scicurious (talk) 14:04, 1 February 2016 (UTC)[reply]
Are you certain it is the connector and not the phone's behavior. I have a phone (Sony) that, when fully charged, will stop charging. Then, a minute later, when it has used a fraction of a percent of power, it will start charging again. It is fully charged, so it stops charging. Then, a minute later, it starts charging again. I can't leave it on the charger overnight because it keeps making the "HEY EVERYONE! I'M CHARGING!" tone every minute. Sony says this is by design to conserve electricity by making it annoying to leave charged phones on a charger. I initially thought the charger and/or the phone was broken until I did enough research to figure out that this was by design. 199.15.144.250 (talk) 15:10, 1 February 2016 (UTC)[reply]
Occam's razor. Don't attribute to malice that which is adequately explained by stupidity. The simplest explanation is that Sony's UX design process is useless. You have strongly deterred me from buying a Sony phone though! 94.12.81.251 (talk) 15:56, 2 February 2016 (UTC)[reply]
I had an old phone that developed spotty charging behaviour, and I found it was just caused by dirt on the charger contacts. Try cleaning both the charger pins and the socket on the phone with a damp cotton bud. It might take a few buds to clear all the muck. 94.12.81.251 (talk) 16:03, 2 February 2016 (UTC)[reply]

N-trig Duo digitizer drivers?

Since N-trig was acquired by Microsoft, the drivers for their DuoSense digitizer have practically disappeared from the Internet. I have a Dell Latitude XT convertible tablet running Windows 8.1 that has this digitizer. Is it possible to find the Windows 8/.1 drivers somewhere? I have looked but cannot find them. — Preceding unsigned comment added by DmitryKsWikis (talkcontribs)

Have you tried Windows 7 drivers? Ruslik_Zero 20:34, 1 February 2016 (UTC)[reply]
You can look at this. Ruslik_Zero 20:37, 1 February 2016 (UTC)[reply]

Printing cheaply

What brand causes less problems when refilling the cartridges? Are they all - inkjet or laser - chipped? Can any one of them be easily refilled at home all by yourself? Can inkjet reach the quality of laser? Is it worth still to buy inkjet, that is, is there any advantage for printing with ink instead of laser nowadays? Laser became quite cheap with the years. --Scicurious (talk) 15:08, 1 February 2016 (UTC)[reply]

If you are OK with black and white laser is cheap, but color laser printers are still a bit pricey. Inkjets are almost always color, but the quality and speed isn't quite as good as lasers (but the best ones are close). You might want to look into Epson's EcoTank Printers. --Guy Macon (talk) 15:39, 1 February 2016 (UTC)[reply]
First and foremost: Inkjet quality will never reach laser quality. For inkjet, the business model of selling a printer at a heavy loss and charging a fortune for ink refills has gone bust. Over the last five years, the companies involved in production of inkjet (and even laser) printers has shrunk. You are now down to Epson, HP, and Canon. They are losing money on inkjet printers as well. So, Epson has a new business model they are trying. They have an "EcoTank" printer. Instead of selling it at a loss, they sell it for a profit. So, they make the money up front. Then, it comes with 2 years of ink in the well. When it is empty, you refill the well with any ink you like. No cartridges. No secret chips. If you are willing to pay more for the printer, the ink becomes very cheap. 199.15.144.250 (talk) 15:27, 1 February 2016 (UTC)[reply]
"now down to Epson, HP, and Canon"? There is also Brother,unless you have a good reason to discard it entirely. --Scicurious (talk) 18:45, 1 February 2016 (UTC)[reply]
You are correct. I have a Brother printer. I was looking at it as I tried to remember the main printer manufacturers and, apparently, my mind decided that since I saw it sitting there, I must not need to type it. 199.15.144.250 (talk) 19:00, 1 February 2016 (UTC)[reply]
I disagree "inkjet quality will never reach laser quality". This may be true for documents since the nature if inkjets means particularly with normal paper they have difficulty achieving the sharpness of lasers, but it definitely isn't true for photos and similar. Particularly when special media is used. Nil Einne (talk) 13:56, 2 February 2016 (UTC)[reply]
I refill HP Laserjet cartridges, including colour, and ignore the chip by using override. The filling can be very messy though because HP don't make it easy, so you need to melt a hole. Dbfirs 17:19, 1 February 2016 (UTC)[reply]
I have two printers, a black-and-white laser printer I use for the bulk of my printing, and a color inkjet for the rare times when a print really needs to be in color. StuRat (talk) 19:24, 1 February 2016 (UTC)[reply]
"now down to Epson, HP, and Canon"? There is also Brother, - And Samsung. My mom got a multifunction laser for Christmas, good machine for the price. ―Mandruss  19:47, 1 February 2016 (UTC)[reply]
You didn't really mention what sort of printing frequency you're expecting. I bought a cheap multifunction Canon inkjet (with rebates it cost about NZD9 or something). I print infrequently enough that the ink hasn't run out yet, but I bought cheap catridges from a local store for future use. If I had wanted to print more, I probably would have gotten catridges from AliExpress/Ebay or perhaps refillable catridges from AliExpress/Ebay + ink. Given the low price of the printer, if it does clog well I'll probably try to clear it by removing the heads and if that doesn't work I'll replace it. Perhaps not the most environmentally friendly option, but it's not my fault if manufacturers want to adopt such a silly business model.

If I had wanted to print even more, perhaps I may have converted the print to use Continuous Ink Supply System. (Well I'm not sure how well the printer I got supports CISS, never looked in to it because wasn't interested.) In some countries there are even Continuous Ink Supply System printers sold locally by major manufacturers, partially because many vendors (including some sellers) will convert other printers to CISS for low prices.

From my experience, with Canon at least (also I think Epson, not sure about HP) it's fairly easy to buy generic chipped catridges even for relatively new printers. (It does raise the cost of the catridge of course but a refilliable catridge with autoresetting chip or a chip resetter are expensive enough that you need to be printing enough to be worth it.)

Nil Einne (talk) 13:54, 2 February 2016 (UTC)[reply]

I thought that was proprietary software on the chip, making it illegal to duplicate (this being the entire point, so the manufacturer can overcharge for ink). StuRat (talk) 16:30, 2 February 2016 (UTC)[reply]
There is no need to duplicate the software, the manufacturer of copied chips just has to read what signals it transmits to the printer and then write new software to duplicate the signals. Some HP printers allow the user to override the toner out signals and thus to reuse old chips with a refilled toner. Dbfirs 20:32, 2 February 2016 (UTC)[reply]
Although StuRat's comment reminded I planned to mention some manufacturers had tried to use the DCMA to prevent such practices. Fortunately this seemed to fail [1] Lexmark International, Inc. v. Static Control Components, Inc. although there could be patent issues. In any case I live in a country without the DMCA actlike laws and if you can find catridges sold by large local sellers unless your a big business yourself such issuess shouldn't really concern you. You should always make sure you can get generic catridges before buying the printer anyway, if you can't the reasons don't concern you. (Although if your printer is fairly common and you can get them from AliExpress/Ebay but not locally this may be a sign there are such issues.) Nil Einne (talk) 05:33, 3 February 2016 (UTC)[reply]

Desktop themes and backgrounds for Windows 10

Does anyone know of any decent websites that have nice desktop themes and backgrounds (for Windows 10)? For free, by the way. I have been to the "official" Microsoft website (here: [2]) and they have very boring and bland ones. I was expecting a lot of really nice ones from them, but was disappointed. Thanks. Joseph A. Spadaro (talk) 18:17, 1 February 2016 (UTC)[reply]

One of the first links in Google search is this. Ruslik_Zero 20:31, 1 February 2016 (UTC)[reply]
Thanks. Yeah, I had seen that. I guess I wasn't impressed. Joseph A. Spadaro (talk) 22:04, 1 February 2016 (UTC)[reply]

Finding a hex color code

I'm trying to find the hex color code for a color named "Pantone 186" and getting more answers than I wanted: #F5002F  , #CE1126  , #D20124  , and #C60C30  , maybe more, not including websafe colors. Questions:

  • Why is there disagreement on this?
  • Is any one source more authoritative?
  • If not, how would one go about choosing which color code to use in a Wikipedia article? ―Mandruss  19:09, 1 February 2016 (UTC)[reply]


Pantone color space is proprietary: so you can't get a straight answer for the exact same reason that you can never know the official formula for Coca Cola... Steve Baker explained this in December 2015:
Nimur (talk) 19:50, 1 February 2016 (UTC)[reply]
You can purchase the spot color chart from Pantone. It looks like a long rectangular thing with swing-out cards, each with 5-6 colors on them. It lists the name of the color, the index, the CMYK values, and the RGB hex code. The chart runs around $100 - which is why people probably don't like to publish it after they spent their hard-earned money on it. 199.15.144.250 (talk) 19:56, 1 February 2016 (UTC)[reply]
So what is the hex code shown on a pantone.com page such as this? A mere approximation of what is on the chart? Sadly, they don't seem to have a page for 186—just multiple variations such as 186 C—or I'd be more than happy to call that authoritative. ―Mandruss  20:09, 1 February 2016 (UTC)[reply]
""The RGB color values printed in the PANTONE® COLOR BRIDGE™ coated are Pantone's official release of RGB values that conform to the sRGB specification." In other words, they are the best possible rendition of Pantone into sRGB. Nimur (talk) 20:24, 1 February 2016 (UTC)[reply]
That implies that what you see on the web page is (deliberately) less than best? ―Mandruss  20:29, 1 February 2016 (UTC)[reply]
But take a real deep breath, and use some caution in choosing your words... because those RGB values aren't the same color as the Pantone color. It doesn't matter how much optical theory you study; how profoundly you understand visible-light spectroscopy; how thoroughly you understand computer graphics and display pixel hardware; how many times you've read Maxwell's treatise on the theory of color vision,...
Pantone claims that it is able to create new colors - and Pantone succeeds at getting lots of money from its clients for those claims. For example, Minion Yellow is claimed to be a new Yellow color. Even if you are able to provide a rendition of Minion Yellow in sRGB (hint... try R=251. G=242, B=117), you aren't actually using "Minion Yellow" unless you're paying the license fee.
So - those three numbers in sRGB space - in fact any scientific procedure you concoct for reproducing the color - aren't the color, per Pantone's business model. You'll have a better chance at understanding this essay, What Colour are your bits?, an article on the confusing concept of intellectual property, and how it is hard for scientifically-minded people to appreciate it.
Nimur (talk) 20:33, 1 February 2016 (UTC)[reply]


The Pantone color is an exact thing, typically set up with carefully controlled pigments in paint, ink and dyes. But computer monitors, TV's and phones vary quite widely in how they reproduce color...aside from anything else, you can adjust the brightness, and perhaps the black-level, contrast and hue - sometimes the 'color temperature' and 'gamma' too. Displays that use cathode ray, LCD or MEMS approaches will vary in color and/or brightness as they age - so a new monitor and and otherwise identical old one may not display the same exact colors for the same exact RGB inputs. Monitors made by different companies will also display color slightly differently. Fiddling with any of those things results in a color that isn't the same as it is on some other monitor. So what RGB value should you shove into the monitor to get the exact pantone color? Who knows? It's different for every monitor.
So it should come as no surprise that there are small (or even not-so-small) variations in the RGB values quoted from multiple sources.
Worse still - a computer monitor can't display all of the colors that humans can perceive - and neither can the inks and dyes that underlie the Pantone system. So there are guaranteed to be pantone colors that computers and TV' simply cannot display AT ALL. In those cases, one generally attempts to find the most perceptably similar color that can be displayed - and that is an artistic compromise in many cases.
SteveBaker (talk) 20:32, 1 February 2016 (UTC)[reply]
I understand that the rendering and perception of any code will vary depending on all the factors you mention, as well as the time of day, the weather, and how long you've been up. Even so, if the University of Cincinnati says their red is Pantone 186, and I want to show that red in their infobox, it seems to me the most logical arbitrary choice is the hex code that Pantone says is their 186. Maybe someone reading this who has one of those charts would care to cough up that code. Failing that, of the four choices above, which would you say best approximates the color sample in UC's trademarks document? Poll! ―Mandruss  20:46, 1 February 2016 (UTC)[reply]
There is no single correct mapping from print color systems like Pantone to emissive color systems like sRGB. It depends at least on the illuminant. It probably also depends on the paper type, which is indicated by a suffix to the Pantone number. The suffixes are listed here. In general I suppose your best bet is to use the official values from pantone.com for a particular paper-type suffix; which suffix you use depends on why you need an sRGB equivalent for the color to begin with. But if your goal is to copy the University of Cincinnati's colors, I think you should sample the sRGB colors from that PDF or their web site, and forget about Pantone. -- BenRG (talk) 20:54, 1 February 2016 (UTC)[reply]
Yep - I agree. They should be happy to accept the color that they, themselves use on their website - and if they don't like your choice - then at least you have solid reasons for what you did. But there isn't a 1:1 mapping between Pantone and RGB and all efforts to make it so are doomed. The last few companies I've worked for specified BOTH the Pantone AND the RGB values that they approve for logos and other important company colors - and that way, they are at least consistent across all of their digital media. They also specify things like font choices and other stuff like how staff photos are posed that helps to keep the company image consistent. SteveBaker (talk) 21:02, 1 February 2016 (UTC)[reply]
I note that the home page red is quite different from the PDF document's red, but I could go with the home page. How do you sample an sRGB color? ―Mandruss  21:06, 1 February 2016 (UTC)[reply]
Various image viewers and editors will show you the web-syntax sRGB color of a pixel if you click on it. IrfanView says the red in this image (used at the upper left of their home page) is #E00122. PNG images can contain color-correction information that makes the interpretation of these values more complicated, but this one doesn't, so use #E00122. If they don't like it it's their fault.
The PDF may not be a good source. If it were supposed to be sRGB-accurate, it would probably list explicit sRGB color values. -- BenRG (talk) 21:33, 1 February 2016 (UTC)[reply]
Ok, that's  . How about the red at the bottom of the page? ―Mandruss  21:35, 1 February 2016 (UTC)[reply]
It's the same (found with Chrome's web inspector, but you could also take a screenshot and then use a program like IrfanView). And this page says #E00122 is correct. -- BenRG (talk) 21:45, 1 February 2016 (UTC)[reply]
LOL. If I had found that page I could have saved all of you a lot of trouble. #E00122 it is. Thanks all. ―Mandruss  21:47, 1 February 2016 (UTC)[reply]
Well, at least one random user get educated. Thank you :) --Edgars2007 (talk/contribs) 21:21, 4 February 2016 (UTC)[reply]

February 2

Mobile editing on Wikimedia projects

When was mobile editing first enabled out of beta for anyone on any Wikimedia project using any method?—azuki (talk · contribs · email) 05:40, 2 February 2016 (UTC)[reply]

@Eat me, I'm an azuki: I do not understand the question. Mobile devices use extra CSS instructions to change the appearance of a website and optimize it for mobile devices, but other than that there is not much of a difference. Before en.m.wikipedia.org existed you could simply use the desktop version of the website on a mobile device. The Quixotic Potato (talk) 04:36, 3 February 2016 (UTC)[reply]
I was asking about editing enabled from en.m.wikipedia.org.—azuki (talk · contribs · email) 10:47, 3 February 2016 (UTC)[reply]
It was sometime just before this date [3]. Nil Einne (talk) 11:57, 3 February 2016 (UTC)[reply]
Yes,but how about through an official WMF app?—azuki (talk · contribs · email) 07:51, 4 February 2016 (UTC)[reply]
Don't know, you only asked about en.m.wikipedia.org or if we generous that you're overspecific maybe the mobile web sites in general. (Your first question is fairly unclear, since as mentioned mobile editing has been supported since browsers supported it. Probably Opera Mini or earlier.) Nil Einne (talk) 17:43, 4 February 2016 (UTC)[reply]

STL maps

Hello. I'm using the STL in C++ and have an object of map class:

 map<vector<signed int>, double>

and I have realized that, in a given map object, all the vector objects are guaranteed to be the same size as each other. I know the size at runtime but not at compile time. In my application, quick running time is paramount. Is there any way to "use" the fact that all the vector objects have the same size? Robinh (talk) 20:17, 2 February 2016 (UTC)[reply]

You might be able to use std::array instead of vector, but measure your program's performance with each before committing. std::array is a C++11 feature, so no good to you if you are stuck with an earlier standard.-gadfium 20:28, 2 February 2016 (UTC)[reply]
Sorry, I missed that you don't know the size at compile time. std::dynarray is the version you might want, but that's a C++14 feature. I think most current compilers will support it.-gadfium 20:35, 2 February 2016 (UTC)[reply]
thanks for this! This seems to be what I'm looking for. I've modified my code but it won't compile, I presume because I have an old version of C++. Can I verify that a dynarray can be used as a key in a map? I am getting confused as to what can and cannot be used as a key. thanks again, Robinh (talk) 20:44, 2 February 2016 (UTC)[reply]
I'm not sure that dynarray is in C++14. I see various reports on the net that it was rejected, and the C++14 article doesn't mention it. It would probably have no advantage over vector except saving one machine word per key (vector typically uses three words for the heap pointer, size, and capacity, but dynarray doesn't need to store a capacity).
If you don't need map's key ordering guarantee, try using unordered_map instead. It will probably be significantly faster.
If the fixed array size will often be small, you could make a template class that takes the size as a compile-time parameter and uses array keys, and a wrapper with a switch-case statement that uses instantiations of the template class for certain sizes and a fallback implementation for other sizes. If you're lucky the compiler will unroll and vectorize the loops in the template code and significantly improve the speed. -- BenRG (talk) 22:24, 2 February 2016 (UTC)[reply]
(OP) yes, unordered_map is *exactly* what I am looking for! I don't need the keys to be ordered. I was a little taken aback to discover that unordered_map allows one to iterate from start to end. My problem now is that I get an "implicit instantiation of undefined template" error, which I simply do not understand (it compiled before, and the only change I have made is to replace "map" with "unordered_ma"). But stackoverflow (which is usually excellent for this sort of thing) isn't helping. Any advice? Robinh (talk) 23:00, 2 February 2016 (UTC)[reply]
Avoid template metaprogramming entirely? Sorry, but you asked for advice...
In total seriousness, we need a larger code snippet before we can evaluate where you went awry, at least with any specificity. "Something somewhere" is illegal syntax, and your compiler is telling you so.
If the exactly only change you made was to replace std::map with std::unordered_map, you should know that these templates have different signatures: unordered_map needs a predicate comparator for equal_to.
Nimur (talk) 23:58, 2 February 2016 (UTC)[reply]
Consider:
#include <map>
#include <unordered_map>
#include <vector>
using namespace std;

map<vector<signed int>, double> my_map;
unordered_map<vector<signed int>, double, std::equal_to<vector<signed int> > > my_unordered_map;


int main(int argc, char** argv)
{
  return 0;
}
... which did successfully compile using my system's c++ compiler, clang.
If neither std::equal_to nor any of its standard alternatives will do what you need or expect... or if its performance does not meet your expectations... you must implement your own binary predicate.
Isn't template programming great? It really makes you totally unable to know whether your efficient optimization will actually run efficiently... Nimur (talk) 01:09, 3 February 2016 (UTC)[reply]
You don't need to specify any extra template arguments to unordered_map. The third argument, if you do specify it, is a hasher, not an equality predicate. Your code probably compiled because you never added anything to the unordered_map, so the ill-typed hasher was never used. -- BenRG (talk) 08:08, 3 February 2016 (UTC)[reply]
Your point is accurate; I shoved the equality operator into the hash function. I could have written better, more completely-defined code by explicitly providing all arguments to all the templates. To be fair, I just made sure the code compiles - not verified that it "works in any specific way." Our OP's original trouble was an error instantiating the template, which is fixed in my listing. The template is instantiatable, but it may behave incorrectly, depending on what you expected it to do.
Maybe I'll write out a more complete listing later as a working example; or perhaps you'd like to provide some code.
Nimur (talk) 17:00, 3 February 2016 (UTC)[reply]
Template classes are not fully instantiated just by declaring a variable of that type. Only if you actually use a method will it be instantiated and type checked. Because you never inserted anything into the unordered_map, none of the associated code was type checked. equal_to<T>() takes two arguments while hash<T>() takes one, so it would have failed the type check. You didn't fix anything.
I linked to working code in my post. -- BenRG (talk) 03:01, 4 February 2016 (UTC)[reply]
I think the problem is that there's no built-in definition of hash<vector<int>>. Since performance is important, you should pick a high-performance hash function like SipHash or xxHash and then specialize std::hash or use a third template parameter as shown here. -- BenRG (talk) 08:04, 3 February 2016 (UTC)[reply]
(OP) OK thanks, I'm beginning to understand. But how come std::map doesn't need a third template parameter if, as you say, there is no built-in definition of hash<vector<int>>? Robinh (talk) 08:39, 3 February 2016 (UTC)[reply]
That is not accurate; the default implementation depends on your implementation (tautologically!) but nearly all implementations use the object-pointer as the key into the hash (often in tandem with an equality check, which is why the template to produce the operator == is an important argument to the template). I think you are led astray again.
For details of LLVM's implementation, see the Programmer's manual entries on std::map and other map-like templates. You will also see that even the compiler programmer manual remarks about the "unique" difficulties of performance when using these sets - so I am in good company when I take a jab at the performance impact! The folks who wrote the LLVM manual even put a smiley-face as they remind you: "As usual, there are a lot of different ways to do this. :)" ....That's your clue that you're about to find the compiler doing something awful and incomprehensible!
Nimur (talk) 16:35, 3 February 2016 (UTC)[reply]
Nimur, you clearly don't understand C++ or the STL. I don't understand why you are responding to this question at all. Nothing that you've said makes any sense. std::map is not a hash table, but an autobalanced binary tree (usually red-black), and does not use a hash function at all. I can't make any sense of the stuff about "using the object-pointer as the key into the hash". Are you talking about some other hash table implementation in some other language? In any case, what I posted is correct; everything that you've written is clutter that I or someone else have to clean up after, because you have no idea what you're talking about. -- BenRG (talk) 03:01, 4 February 2016 (UTC)[reply]

February 3

more STL questions

First of all, thank you to everyone who helped me yesterday; I really appreciate it. Now, why doesn't the following code compile?

#include <unordered_map>
#include <vector>
#include <utility>
#include <iterator>

typedef std::vector<signed int> myvec;
typedef std::unordered_map<myvec, double, std::equal_to<std::vector<signed int> > >  uom;  

int f(){
    
    myvec v;
    uom S;
    
    v.clear();
    v.push_back(3);
    v.push_back(-3);
    
    S[v] = 4.4;
    
    return (0);
}

The compiler gives a whole bunch of error messages starting with

Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:386:17: error: no matching function for
     call to object of type 'const std::__1::equal_to<std::__1::vector<int, std::__1::allocator<int> > >'
       {return static_cast<const _Hash&>(*this)(__x);}
               ^19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:2014:21: note: in instantiation of member
     function 'std::__1::__unordered_map_hasher<std::__1::vector<int, std::__1::allocator<int> >, std::__1::__hash_value_type<std::__1::vector<int,
     std::__1::allocator<int> >, double>, std::__1::equal_to<std::__1::vector<int, std::__1::allocator<int> > >, true>::operator()' requested here
   size_t __hash = hash_function()(__k);

I don't understand these messages, can anyone advise? Thanks, Robinh (talk) 19:59, 3 February 2016 (UTC)[reply]

Don't use Nimur's code; it is wrong (and causing compilation errors) for reasons unrelated to your problem. To use unordered_map, just replace map with unordered_map in your code and provide a hash function for vector<int>. In the previous thread I linked to a couple of possible hash functions and an explanation of how to use custom hash functions with unordered_map. -- BenRG (talk) 03:06, 4 February 2016 (UTC)[reply]

February 4

Question (How are CPS made ?)

how are cps made — Preceding unsigned comment added by Jake200503 (talkcontribs) 02:34, 4 February 2016 (UTC)[reply]

Can you please clarify, it's entirely not clear what you mean by CPS, even if we narrow the field to computing there's a half dozen possibilities of what you could mean. Vespine (talk) 04:12, 4 February 2016 (UTC)[reply]
I added to the title to make it unique (although still not clear). StuRat (talk) 04:39, 4 February 2016 (UTC) [reply]

SQL query condition question

I recently ran into the following problem at work.

We have a database table that includes rows that should be processed every x months. How much x is depends on the row and is written to a field in the row. There is another field saying when the row was last processed.

I wanted to make a database query selecting every row that should now be processed, as enough time has been passed since it was last processed. Turns out this was not so easy, as the condition to write to the where section would have to change between individual rows.

Let's say the table name is thing, and lastprocessed means when it was last processed, and processinterval means how many months it should be processed between. So the format is something like: select * from thing where lastprocessed < :date and processinterval = :interval.

I ended up making separate queries for every value of processinterval (there are a finite number of them, and not quite many), computing :date separately for each of them, and then combining the results.

Is there an easier way to do this? JIP | Talk 21:02, 4 February 2016 (UTC)[reply]

If you're using SQL Server you can do something like this. If not, you could write a function that returns the specific date based on the processinterval and then call the function in the lastprocessed < :date portion, setting the :date to be getdatebyinterval(processinterval)'s return value. I'm not sure if you need specific permissions to create a function on a database; I assume so, but YMMV. I'd also assume that if you're doing this at work then you probably have the permissions. I'm not sure how good a solution this is for your particular workplace. The third option is to hit the database once and get all relevant rows in thing , and then have whatever application is using the data figure out which to process instead of having the database try to. FrameDrag (talk) 21:41, 4 February 2016 (UTC)[reply]

SSD, virtual memory, thrashing

In short: will adding an SSD drive generally give notable improvements to thrashing issues?

In long: I have a series of computations I need to run for my research. This partly involves smacking together lots of relatively large arrays. Things go great for size parameters of about 45x45x10k, and the things I want to run complete in a few hundred seconds. Apparently things mostly fit into my 16GB RAM, and only a few larger swaps to virtual need to be done. But if I increase those sizes to say 50x50x15k, I hit a memory wall, get into heavy swapping/thrashing, and the thing can take about 20 times longer, and that's not ideal. It's not so much the time increase that bothers me, but that I've shifted into a whole new and worse domain of effective time complexity. So: would buying a few gigs (16?) of SSD to use as virtual memory generally help speed things up for the latter case? I know more memory would help, but all my DIMM slots are full, and I think I can get a solid drive for a lot less than 4 new RAM chips above 4Gb each. Actually I may be very confused and wrong about this, as I haven't payed much attention to hardware for years, maybe more RAM could be comparable cost and more effective. Any suggestions? (And if you happen to be decently skilled at scientific computing and are looking for something to work on, let me know ;) SemanticMantis (talk) 21:14, 4 February 2016 (UTC) [reply]

In short, yes, sticking the windows swapfile on an SSD is highly recommended, and considering you can get a 64GB SSD for about $70 (I don't think you'll find a 16GB one these days), it's a bit of a no brainer these days. It used to be a but controversial in the early days of SSD because it heavily utilizes the disk and early SSDs didn't have very high read write cycles, but that's not so much of a concern anymore. How much performance increase you see is hard to predict, but it could be anything from "a bit" to "loads". Vespine (talk) 22:00, 4 February 2016 (UTC)[reply]
Thanks, it seems I am indeed out of touch with prices and sizes. This is for use with OSX by the way, but I'm sure I can figure out how to use the SSD for virtual memory if/when I get one. If anyone cares to suggest a make/model with good latency and value for the price, I'd appreciate that too. SemanticMantis (talk) 22:17, 4 February 2016 (UTC)[reply]
Adding more memory will generally be MUCH MUCH more effective than using a faster (SSD) disk. Even if the memory in the SSD is as fast as RAM (and it almost certainly isn't), the overhead in passing a request through the virtual memory system and I/O system, sending it over the (slow) interface to the disk, getting the response back over the same slow interface, getting it back up the software stack to the requesting thread, waking up and context-switching into the thread, is going to be many times slower than a single memory access. Now consider that nearly every CPU instruction could be doing this (which is pretty much the definition of thrashing). Moving to a SSD disk will certainly improve performance over a mechanical disk, but it will be nowhere near the performance increase you would get by increasing the size of physical memory to be larger than the working set of your processes. Mnudelman (talk) 22:24, 4 February 2016 (UTC)[reply]
I'm not as familiar with OSX or Linux but I get the impression moving the swap file is not quite as straight forward as windows. If I were you, i would consider getting a bigger SSD instead, doing a full backup to an external drive and then restore your entire system to the SSD disk. That way you will see improvement benefits above and beyond what you'd get from just sticking the swap file there. I personally use the Samsung 840 (now the 850), they're stalwarts in the reviews for "best bang for the buck" category. Vespine (talk) 22:30, 4 February 2016 (UTC)[reply]
Kingston 8GB 1600MHz DDR3 (for MacBook Pro, but I suspect thats not too atypical) is a bit over US$40, so for 32 GB you'd pay US$ 170 or so. As others have said, an SSD is better than a mechanical drive, but RAM is so much better than SSD that it's not even funny. --Stephan Schulz (talk) 22:41, 4 February 2016 (UTC)[reply]
Well, I agree RAM is "better than SSD", but ask anyone what the best improvement to their computers has been in the last 10 years and almost universally it's getting an SSD. The other thing you COULD consider is get 16GB in 2 sticks and replace 2 of your sticks for a total of 24GB. It is "more" usual to have 16 or 24, but having 2 matching but different pairs should still work fine. if that's enough to push you "over the line" you can leave it at that, if it's not you can always get another 16GB pair later. Vespine (talk) 22:46, 4 February 2016 (UTC)[reply]
Yes, that does change things in the cost/value analysis; I forgot not all RAM chips have to match (anymore)? SemanticMantis (talk) 00:16, 5 February 2016 (UTC)[reply]
As a general concept it's true that SSD is a big improvement to performance but only if the bottleneck is the disk in the first place. That's not what the OP is describing; he is in a THRASHING scenario. Improving disk speed is a terrible way to address thrashing.
Also consider that when you need to swap to read a single word, you have to free up some RAM first, which probably means WRITING a PAGE of memory to the SSD, then reading another PAGE of from the SSD back to RAM. Depending on the page size, this will be hundreds or thousands of times slower than it would be to read the word from RAM if swapping is not needed, even ignoring other overhead like disk/interface speed and context switching. Mnudelman (talk) 22:49, 4 February 2016 (UTC)[reply]
Improving disk speed is a terrible way to address thrashing. Except it's not a "terrible" way at all, microsoft recommend sticking your swap file on an SSD if you can. We're getting superlatives mixed up. YES more ram is better than a faster disk but a faster disk is NOT a "terrible" upgrade. Vespine (talk) 23:27, 4 February 2016 (UTC)[reply]
My 1st reply was actually going to be "it might be hard to predict how much improvement you will see upgrading to an SSD" but they I read the 1st line again, WILL AN SSD GIVE NOTABLE IMPROVEMENT IN A THRASHING SCENARIO" and my answer, in short, which i still stand by, is yes, yes it will. More RAM will probably be better, but getting an SSD IS also just a GOOD upgrade overall. Vespine (talk) 23:29, 4 February 2016 (UTC)[reply]
Yes, an SSD for virtual memory will be faster than a HD, but not a whole lot faster. Definitely maximize your motherboard's RAM first. Bubba73 You talkin' to me? 23:56, 4 February 2016 (UTC)[reply]
Right, so I know more RAM will be the best way to solve the problem. But given a fixed budget, I'm not clear on how to optimally spend it. For example, I can get 8 more GB of ram for around $110 [4]. That will give me more room, but may well put me straight back to thrashing at 52x52x15k, to continue the example numbers from above. I can get 128GB SSD for $60 [5]. For a certain fixed size computation, that will not give me as much speed increase as more RAM would. But, if I'm hitting a RAM wall regardless, then the increased read/write speed should help me out with a lot of thrashing issues, no? It's not like it's thrashing so bad it never stops, or crashes the computer. Just puts me into a much higher exponent on time complexity. To make things up: say I was at O(n^1.1) up to a certain size N. For M>N, the thrashing puts me at O(M^3). With 8 (or 16)GB more RAM, thrashing may set in at M2=M+K, but I'm still at O((M+K)^3) after that. With a new SSD, I thought maybe I could get to O(M^2) for M>N, up to some larger cap on the size of the SSD. (yes I know this is not exactly how time complexity works, I'm just speaking in effective, functional terms of real-world performance on a certain machine, not analysis of algorithms. For that matter, nobody has yet suggested I just get better at managing my computing resources and being more clever at organizing things efficiently, but rest assured I'm working on that too :) SemanticMantis (talk) 00:10, 5 February 2016 (UTC)[reply]
In terms of bang for your buck, have you looked into just buying computing resources from a "cloud" provider instead of running things on your personal computer? --71.119.131.184 (talk) 00:33, 5 February 2016 (UTC)[reply]