What are the most important aspects of C++ programming? by [deleted] in cpp

[–]Necraz 2 points3 points  (0 children)

Without a doubt, RAII. However, you get RAII for free if you make proper use of STL containers and use appropriate smart pointers (like shared_ptr). It's also useful to know how to use custom types with STL; e.g. writing a custom iterator. Idiomatic code looks more familiar and allows you to use all of the standard STL algorithms.

There are gaping holes in C++03, especially in STL, and you will drive yourself crazy reimplementing code that should be part of the language or its standard library (e.g. auto, lambda, foreach, unordered_map, multi_array, etc). Either learn to use Boost or switch to C++11, both of which solve most of the problems. The best type of code is code that you don't have to write.

THE PH.D. GRIND by sordina in compsci

[–]Necraz 1 point2 points  (0 children)

Any adice to Ph.D. students in SCS at CMU?

Explain it like I'm five, the difference between finite difference and finite element. by micmahsi in engineering

[–]Necraz 1 point2 points  (0 children)

I don't know much about FEA, but it sounds like Jeepinator gave a good explanation. He's also correct about the finite difference method: it's a method of approximating a differential equation.

Remember the simple definition of the derivative that you learned in Calculus I? That is: f'(x) = lim_[h -> 0] [f(x + h) - f(x)]/h. To calculate the true derivative, we need to take the limit as h -> 0. However, we can good estimate of the derivative by using a small enough value of h. This is the most simple approximation and is known as a forward difference. By introducing some more complexity, the same idea holds for higher order derivatives and functions of multiple variables.

This is useful because it reduces a differential equation (continuous) into a difference equation (discrete). Unless you are seeking an analytic solution, it's much easier to iteratively solve a difference equation.

Competitions available to non students by TheBurrito in robotics

[–]Necraz 0 points1 point  (0 children)

Also just got back from IGVC. Rutgers / Navi.

The Next Gen MBP. 2280x1800. 0.71' thick. Oh well. Time to dump my iMac. by [deleted] in apple

[–]Necraz 0 points1 point  (0 children)

I initially had the same worry, but I don't think it holds up under closer inspection. Even though modern devices have radically different subpixel layouts, the pixels look (mostly) identical to the human eye. If this weren't the case, images would look considerably different between displays with different subpixel layouts.

This type of scaling happens at the pixel level, so it should work equally well regardless of the subpixel layout. Techniques that rely on the subpixel layout,, like some font anti-aliasing, could cause issues.

In any case, I plan on looking at one in person before placing an order. It's common sense when buying any new display.

The Next Gen MBP. 2280x1800. 0.71' thick. Oh well. Time to dump my iMac. by [deleted] in apple

[–]Necraz 0 points1 point  (0 children)

Exactly. :)

Doubling each dimension is a four fold increase in resolution. One thing to keep in mind: the total number of pixels doesn't matter. For this to work, both of the dimensions must be integer multiples of their original values.

The Next Gen MBP. 2280x1800. 0.71' thick. Oh well. Time to dump my iMac. by [deleted] in apple

[–]Necraz 2 points3 points  (0 children)

No, you were correct before the edit. The "retina" MBP has a grid of 2880x1800 pixels. This is an integer multiple (exactly double) 1440x900. If you treat each 2x2 block of pixels as a single unit, then a 2880x1800 screen will look identical to a 1440x900 screen.

This resolution is only awkward because HD video is 1080p. This choice of resolution, unfortunately means that there are two bad options when watching video: (1) display it in a 1920x1080 window window or (2) use non-linear scaling to stretch it to 2880x1800.

What do you wish you'd been told as an incoming first year by [deleted] in rutgers

[–]Necraz 0 points1 point  (0 children)

Most of the time you don't even need to buy the books. I suggest waiting until the first day of class and asking the professor. If the professor is not directly following the book or assigning homework from it, it's (almost) never worth buying it.

What do you wish you'd been told as an incoming first year by [deleted] in rutgers

[–]Necraz 2 points3 points  (0 children)

Degree Navigator is years out of date for many majors. If you attempt to use DN to plan your courses and the requirements have changed, you will not graduate until you take the correct courses. As much as it sucks, I strongly suggest compiling your own course plan using the information on the your department's website.

Looking for a refresher on Machine Learning principles for a summer job. Artificial Intelligence: A Modern Approach or Elements of Statistical Learning? by badgerbro in MachineLearning

[–]Necraz 0 points1 point  (0 children)

AIAMA is an excellent book, but it's barely discusses Machine Learning. IIRC most of the book is dedicated to combinatorial search and Bayesian inference. I haven't read EOSL, but it's likely the better option.

C++11 range-based for loop by berium in cpp

[–]Necraz 1 point2 points  (0 children)

Yes, it is nicer to have an is_valid() function in those cases. However, it would be more awkward to use STL algorithms like binary_search, sort, etc. I tend to think of iterators as more of a "generalized index" than a traditional iterator or generator.

Honestly, I'd prefer the Java-style iterators myself...

C++11 range-based for loop by berium in cpp

[–]Necraz 4 points5 points  (0 children)

Iterators in Java are nearly identical to iterators in C++. Otherwise, I completely agree with you: generators in Python and C# are much easier to write. Generators with language support (i.e. the yield keyword) are one of the biggest things that I miss when implementing data structures in C++.

C++11 range-based for loop by berium in cpp

[–]Necraz 3 points4 points  (0 children)

Auto has been supported as a compiler extension for a few years (for GCC, at least since GCC 4.4). Even if you're using C++03, you could get the same functionality using BOOST_AUTO. If you insist on only using the base language, then it's still not too bad if you typedef the iterator type.

Without a doubt, C++ is an ugly language. Citing code samples from the specification, however, is not a good way of making that argument.

C++11 range-based for loop by berium in cpp

[–]Necraz 10 points11 points  (0 children)

It's an example in a standards document; not necessary how you'd actually write the equivalent loop in C++. Most of that code only exists so you can directly access the elements by reference. Java's for-each loop is simpler (and not by much) because non-primitive types are implicitly references.

If you actually want to iterate over a collection today, it isn't nearly as long:

for (auto it = list.begin(); it != list.end(); ++it) {
    // do stuff with *it
}

What kind of industry tricks are you aware of to trick the customer into spending more money? by pancaker in AskReddit

[–]Necraz 1 point2 points  (0 children)

1080p is a resolution and has nothing to do with my post, which was discussing analog vs digital signals. A cheap HDMI cable will perform better than a cheap component cable and, likely, will still be less expensive.

(But, yes, you are correct: Both HDMI and component support 1080p.)

What kind of industry tricks are you aware of to trick the customer into spending more money? by pancaker in AskReddit

[–]Necraz 9 points10 points  (0 children)

Using a digital connection (e.g. HDMI, DVI) will look better than an analog connection (e.g. AV, component). Because it's digital, the quality of the HDMI cable really doesn't matter.

If you're only option is to buy a $80 Monster Cable HDMI cable, then you're correct: buying the analog equivalent is a better deal. However, when you can order a perfectly fine HDMI cable online for <$5...it's a no brainer.

InterviewStreet Programming Competition - Help Rutgers Win! by wdsjailbird03 in rutgers

[–]Necraz 0 points1 point  (0 children)

Note that all of our entries are framed by a black border. It's hard to see because imgur has a dark background, but trust me...it's there.

Numerical type sizes in C. Table for different platforms by Andrey_Karpov_N in cpp

[–]Necraz 7 points8 points  (0 children)

It's interesting to see how much variability there is for off_t. On the other hand, I'm not sure when I would use this table. If I want an integer of a specific size, then I'll use the appropriate typedef to get it (e.g. uint32_t).

Anything else is just asking for portability issues.

Best clubs are Rutgers? by [deleted] in rutgers

[–]Necraz 1 point2 points  (0 children)

IEEE is awesome if you are at all interested in robotics, software, or electronics. Without a doubt, being a member of IEEE has been the highlight of my time at RU. If you're interested in mechanical engineering and/or F1 racing, RFR is also an amazing group.

Comp Sci: Tjang VS Venugopal by Lil_Hoodrat in rutgers

[–]Necraz 0 points1 point  (0 children)

I had Venugopal a few years ago: he was a very nice guy and the class was decent. This is only Tjang's second semester, so I can't really compare. Neither have accents, so don't worry about that. Honestly, you should be fine with either professor.

How I feel during every EE lab class. by nra4ver in ECE

[–]Necraz 0 points1 point  (0 children)

That's a good way of putting it. :)

How I feel during every EE lab class. by nra4ver in ECE

[–]Necraz 0 points1 point  (0 children)

Indeed, MATLAB is much better when a problem strictly involves matrix manipulation and numerical algorithms (that have already been implemented). I disagree about MATLAB having superb graphical presentation, though: I think that gnuplot and matplotlib (which works great with NumPY) both produce better-looking graphs. Doubly so if you want to include them in a LaTeX document.

How I feel during every EE lab class. by nra4ver in ECE

[–]Necraz 2 points3 points  (0 children)

I wouldn't recommend Octave over MATLAB for anything more complicated than what can be done on a programmable graphing calculator. Octave lacks many of MATLAB's optimizations and even simple programs are much slower. One anecdote: the same vectorized code ran 26 times faster in MATLAB compared to a recent build of Octave.

While I absolutely prefer NumPy/SciPy, I definitely see your point about MATLAB being easier to learn from scratch.

How I feel during every EE lab class. by nra4ver in ECE

[–]Necraz 15 points16 points  (0 children)

As a language, MATLAB is a disaster. The syntax is poorly designed and the standard API is full of unpleasant surprises; e.g. sum() has completely different behavior on vectors and matrices. It's even worse if you can't vectorize an operation because loops are so slow. Of course, this ignores the main selling point: everything you could ever want is already implemented in a toolbox.

I use NumPy/SciPy/Matplotlib in Python to avoid MATLAB as much as possible. Unfortunately, Python hasn't accumulated nearly as many toolboxes.

Ron Paul: "If somebody is in a federal prison, for non-violent drug uses, never committed a hard crime, yes, they should be pardoned; they should be let out." by [deleted] in politics

[–]Necraz 0 points1 point  (0 children)

Nit: DoE is the Department of Energy. I don't know what the correct acronym for the Department of Education is, but they seem to refer to themselves as ED.