|
I would hazard if Element is packed by compiler attributes the struct wrapper would promote to machine alignment.
|
# ? Jun 3, 2012 03:41 |
|
|
# ? Jun 7, 2024 19:22 |
|
It is guaranteed if you writecode:
|
# ? Jun 3, 2012 04:02 |
|
I'm looking to learn the basics of C++ this summer and I'd like a nice book to help me along the way. Anyone have any recommendations? I know there's probably free stuff on the Internet, but I still want a book. I was looking at this one since the reviews are good and it was published in October 2011, so it's probably pretty up to date. I know the basics of Java, so I don't need an introduction to programming or anything. I'm okay with spending up to $50.
|
# ? Jun 3, 2012 06:19 |
|
Matazat posted:I'm looking to learn the basics of C++ this summer and I'd like a nice book to help me along the way. Anyone have any recommendations? I know there's probably free stuff on the Internet, but I still want a book. I was looking at this one since the reviews are good and it was published in October 2011, so it's probably pretty up to date. I know the basics of Java, so I don't need an introduction to programming or anything. I'm okay with spending up to $50. Koenig & Moo.
|
# ? Jun 3, 2012 09:28 |
|
tractor fanatic posted:Do I get some kind of guarantee in C++ that No (there could be padding tacked on), but you do get a guarantee that the address of the struct and that of its first element are the same
|
# ? Jun 3, 2012 22:41 |
|
shrughes posted:It is guaranteed if you write
|
# ? Jun 3, 2012 23:01 |
|
I've been wracking my brain on this problem all afternoon. I need to write a program that calculates pi using the formula pi = 4 - 4/3 + 4/5 - 4/7... Easy enough. The problem I keep running into is my loop always runs a final time after my counter is equal to my loop parameter. code:
|
# ? Jun 5, 2012 00:38 |
|
jhunter46 posted:Essentially I need the final value of pi to be the nth calculation as entered by the user but I keep getting the nth + 1 value. I'm sure I'm missing something obvious, but I can't figure out what that is. The first term is just 4, right? So you need the loop to run once if piTerms == 2, twice if piTerms == 3, and not at all if piTerms == 1. But count starts at 1, and the if condition is count <= piTerms.
|
# ? Jun 5, 2012 00:47 |
Off-by-one errors are often caused by a comparison operator not being sharp when it should be, or being sharp when it shouldn't. Check your loop condition.
|
|
# ? Jun 5, 2012 00:48 |
|
I think I just had to sleep on the problem. I changed the algorithm and instead of using modulus division, I used a flipping Boolean. In addition my loop was treating n0 as n1 which it shouldn't because a 0 iteration loop is prohibited by the input restrictions. I also moved the portion of the loop that read the value of pi every nth time to after the calculation had been complete. My final output doesn't perfectly match what we were given as an example, but that loop was also treating n1 as n0, which isn't correct. Thanks!
|
# ? Jun 5, 2012 14:28 |
|
I'm pulling my hair out hereC++ code:
raminasi fucked around with this message at 20:20 on Jun 9, 2012 |
# ? Jun 9, 2012 20:15 |
|
I have a question specifically about Visual Studio. Is there something I am missing that I need in order to get more friendly tooltips? Here is an example: In C# this would have maybe a short description of what this function does and some more decipherable parameters. Does such a thing exist for C++?
|
# ? Jun 10, 2012 04:00 |
|
Does an image processing algorithm exist that can take a black white image and perform some sort of hashing on it that will.produce the same output "hash" regardless of whether or not the image is a perfect copy of the original. My interest is in the error tolerance of biometric finger print scanners and how they can pass/fail a scan given the inherent "fuzziness" of the input data. Any input on this or how biometric auth works would be rad.
|
# ? Jun 10, 2012 07:14 |
|
cr0y posted:Does an image processing algorithm exist that can take a black white image and perform some sort of hashing on it that will.produce the same output "hash" regardless of whether or not the image is a perfect copy of the original. My interest is in the error tolerance of biometric finger print scanners and how they can pass/fail a scan given the inherent "fuzziness" of the input data. I did something similar recently, and I followed something roughly similar to what these guys did: http://phash.org/ except I averaged colors based on a grid where I expected certain things to be.
|
# ? Jun 10, 2012 07:20 |
|
Assuming you have two true black and white bitmaps (literally one bit per pixel), you already have a "hash". You can find the differences between the two hashes, and set rules about tolerance in the domain of fingerprints. A bit of research on fingerprints should show you the most important parts of fingerprints, of which you have little tolerance between images.
|
# ? Jun 10, 2012 07:22 |
|
Actually, for fingerprints, look at the work the NIST has done with their latent fingerprint system and biometric image software.
|
# ? Jun 10, 2012 07:28 |
|
IratelyBlank posted:I have a question specifically about Visual Studio. Is there something I am missing that I need in order to get more friendly tooltips? Here is an example: Are you asking about creating them for your own code, or the standard library? Visual C++ supports documentation comments, and comments you put on the line above or the same line after seem to get automatically slurped into the tooltips if you've got nothing else (this is something that I've just noticed, not done exhaustive testing on, and I don't know what happens if you have both). I think for the standard library you're out of luck, though.
|
# ? Jun 10, 2012 09:39 |
|
cr0y posted:Does an image processing algorithm exist that can take a black white image and perform some sort of hashing on it that will.produce the same output "hash" regardless of whether or not the image is a perfect copy of the original. My interest is in the error tolerance of biometric finger print scanners and how they can pass/fail a scan given the inherent "fuzziness" of the input data. You might want to play around with phash/perceptual hashes - http://phash.org.
|
# ? Jun 10, 2012 15:38 |
|
hieronymus posted:You might want to play around with phash/perceptual hashes - http://phash.org. Cool, I will definitely start playing with this (anyone else feel like the biggest nerd on the planet when they realize "dude this is so awesome an algorithm to compare dissimilar images! ". On that note, is there any way that I can capture a finger print scan from a common laptop finger print reader (the kind with the little strip of gold metal). I don't have enough of an understanding as to what the device is actually sending to the machine. I sniffed the usb traffic (which is how it interfaces) but don't seem to be getting anything useful. I am thinking the chip in the device might be doing it's own analysis and simply sending a pass/fail to the host system, but am not sure. or some other non-technical way of digitizing my own fingerprint?
|
# ? Jun 10, 2012 22:45 |
|
Don't use perceptual hashes for fingerprints. You need to use something to detect minutiae.
|
# ? Jun 10, 2012 23:52 |
|
I'm seeing some weird behavior with snprintf on ARM. I have a call that looks like this:C++ code:
When the snprintf call is made inside the function with the %f format specifier, it either fills in nothing for that part of the format string or a bunch of zeroes regardless of the value passed for that slot in the format (even literals like 3.14f). When an identical call is made in main, it works as expected. When format specifiers other than %f are used, it works as expected either when called from main or from inside the other function. What is it most likely that I've blown up? I rather doubt that I've found such a basic bug in glibc for ARM.
|
# ? Jun 12, 2012 00:07 |
|
Otto Skorzeny posted:What is it most likely that I've blown up?
|
# ? Jun 12, 2012 00:13 |
|
roomforthetuna posted:Is the function in a different file from main? If so it's possible that "struct foo" has ended up packed differently in the two files, which might be remedied with an appropriate #pragma pack in the header that declares the struct. I will investigate this, but I don't think it fits the data well. I may not have been explicit enough earlier, but when I swap in a literal like this: C++ code:
|
# ? Jun 12, 2012 00:31 |
|
Try swapping foo_to_string out for that line alone, and make sure it gets called. And then print the buffer immediately after.
|
# ? Jun 12, 2012 00:38 |
|
Is it actually calling snprintf()? A quick Google suggests that the ARM compiler will rewrite printf calls to different functions depending on whether or not you're passing them float arguments. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3933.html
|
# ? Jun 12, 2012 01:06 |
|
Sure it's a float and not being converted to a double? What happens with "%lf"?
|
# ? Jun 12, 2012 04:20 |
|
That's not the problem, C will upconvert floats to doubles when passing them to variable argument lists. %f is the format specifier that prints a double.
|
# ? Jun 12, 2012 05:50 |
|
I'm only suggesting this because you seem relatively well into "what the everloving gently caress territory," but I've had success fixing bugs that weird by just blowing all my intermediate files away and rebuilding the entire binary from scratch (assuming you haven't done that yet).
|
# ? Jun 12, 2012 08:35 |
|
GrumpyDoctor posted:I'm only suggesting this because you seem relatively well into "what the everloving gently caress territory," but I've had success fixing bugs that weird by just blowing all my intermediate files away and rebuilding the entire binary from scratch (assuming you haven't done that yet). ._. I just did this and poo poo works again. What the hell, PSoC Creator/ARM gcc 4.4.1?
|
# ? Jun 12, 2012 13:15 |
|
What's the point of code like this?code:
If you aren't going to do anything with the value, why not write code:
|
# ? Jun 12, 2012 13:49 |
|
A dumb way to silence unused return value warnings, perhaps. Probably just bad code.
|
# ? Jun 12, 2012 14:12 |
|
But then Visual Studio complains about "Empty controlled statements"... Thanks.
|
# ? Jun 12, 2012 14:48 |
I'm trying to get started on using OpenCL, but ran into trouble getting a sanity-friendly overview of what I need to write code that will run on any OpenCL-capable hardware. I looked at the SDKs on offer from the big three (Nvidia, AMD, Intel), but found them all ambiguous on whether any code written with them would actually work on hardware from the other manufacturers. The Nvidia CUDA toolkit in particular doesn't give any indication of being helpful for anything other than CUDA programming. Google searches hinted that there was once an Nvidia OpenCL SDK available at http://developer.nvidia.com/opencl, but it seems to have vanished since then in that case. Anyone want to help me make sense of this and perhaps point me in the direction of a good OpenCL sdk (for windows/VS2010)?
|
|
# ? Jun 13, 2012 18:10 |
|
The CUDA Toolkit includes nVidia's OpenCL libraries. I'm pretty sure you have to compile against the hardware vendor for the target machine, so if you need to support both nVidia and ATI cards you'll have to provide binaries for both, or provide source and have your customers build it themselves. If you're on Windows exclusively you could look into DirectCompute (or C++ AMP, which is built on it) which will work without recompilation on both vendors. If this is just a learning project then just grab the SDK from your video card's manufacturer and go nuts.
|
# ? Jun 14, 2012 01:40 |
Thanks! I'm doing an implementation of the water and erosion simulator that From Dust also used to serve as the basis for my thesis project, but I'd also been aiming at making it robust enough to be useful to others since there didn't seem to be any existing open source implementations of it. I guess I'll go with the CUDA toolkit for now in the name of expediency.
|
|
# ? Jun 14, 2012 02:05 |
|
Paniolo posted:The CUDA Toolkit includes nVidia's OpenCL libraries. I'm pretty sure you have to compile against the hardware vendor for the target machine, so if you need to support both nVidia and ATI cards you'll have to provide binaries for both, or provide source and have your customers build it themselves. Most of the vendor's out there follow the Installable Client Model (icd) extension, which allows you to query all available opencl platforms on a given machine, whether they are from the same vendor or not. You simply need to install their runtime for it to work. You can read more about it here. It gives a few examples, but AFAIK Intel, AMD, and Nvidia all follow the ICD.
|
# ? Jun 14, 2012 22:33 |
|
Contains Acetone fucked around with this message at 17:51 on Jun 24, 2020 |
# ? Jun 15, 2012 02:53 |
|
Is there a reason a CGI program written in C++ (even very basic "hello world") would work perfectly on the server when compiled with optimizations off, but give a 500 Internal Server Error with -O1 or anything more? It runs fine on my local machine with either option. I'm compiling on the same architecture as the server (x86-64 linux). Does g++ do optimizations that are only valid for my [distribution/processor/kernel/something else] or something? Am I naive to expect it to work without compiling it directly on the server? (getting shell access is possible but a bit of a hassle. It's probably not actually a big deal to just leave optimizations off but now I'm curious)
seiken fucked around with this message at 15:19 on Jun 16, 2012 |
# ? Jun 16, 2012 15:15 |
|
seiken posted:Is there a reason a CGI program written in C++ (even very basic "hello world") would work perfectly on the server when compiled with optimizations off, but give a 500 Internal Server Error with -O1 or anything more? It runs fine on my local machine with either option. I'm compiling on the same architecture as the server (x86-64 linux). Does g++ do optimizations that are only valid for my [distribution/processor/kernel/something else] or something? Am I naive to expect it to work without compiling it directly on the server? (getting shell access is possible but a bit of a hassle. It's probably not actually a big deal to just leave optimizations off but now I'm curious) Issues that only appear when optimization is on usually mean a bug in your code that didn't manifest itself without optimizations. For example, in this fragment of code: code:
It shouldn't be doing optimizations that are only valid on your local machine, so I doubt it's that -- you should totally be able to compile on your machine.
|
# ? Jun 16, 2012 17:07 |
|
|
# ? Jun 7, 2024 19:22 |
|
So I don't understand why there is no way to specify a deleter for allocate_shared. I'm trying to decide if I should care or not. What I'm doing is I've written my own specialized allocators that, in summary, basically allocates a pool of memory up front. And under certain compile conditions keeps track of some memory stats, etc. Now, make_shared / allocate_shared main advantage is that they create the shared pointer, the bookkeeping, and the object in one allocation. Which is a decent optimization. But there is no way to give these factories a deleter which makes them useless for what I want to do. But again, I'm not sure if I should care. The main advantage of my allocators is that the memory is allocated up front, so there should be minimal impact when I create a new object since I don't have to do dynamic memory allocation at that moment. With that in mind does it matter that by not using allocate_shared I will be requesting memory from my allocator in two distinct steps by using the shared_ptr directly to specify the allocator and deleter? I guess I should benchmark it but my gut feeling is that since my memory is allocated up front the two distinct memory requests won't be such a big deal as it normally would be. I just can't help feeling like I'm being denied the opportunity of having all that space reserved in one call. xgalaxy fucked around with this message at 17:33 on Jun 16, 2012 |
# ? Jun 16, 2012 17:27 |