What's the Point of G++ -Wreorder

What is the difference between %g and %f in C?

See any reference manual, such as the man page:

f,F

The double argument is rounded and converted to decimal notation in the style [-]ddd.ddd, where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it.
(The SUSv2 does not know about F and says that character string representations for infinity and NaN may be made available. The C99 standard specifies '[-]inf' or '[-]infinity' for infinity, and a string starting with 'nan' for NaN, in the case of f conversion, and '[-]INF' or '[-]INFINITY' or 'NAN*' in the case of F conversion.)

g,G

The double argument is converted in style f or e (or F or E for G conversions). The precision specifies the number of significant digits. If the precision is missing, 6 digits are given; if the precision is zero, it is treated as 1. Style e is used if the exponent from its conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit.

What is the point of Big-Omega asymptotic notation?

The Big-Omega is reverse to O

If this is true : f(x) = O(g(x)) then it means this is also true g(x) = Omega(f(x))

By "human words" you can say - if f(x) is at most as complex as g(x), then g(x) is at least as complex as f(x)


It is something "more" than just measurment of most optimistic time for alghoritm.

PS : But for measurment of real-life alghoritms, you are basically right. You are interested in either worst case or in average case (i.e. quicksort)

What's the point of including -std=c++0x in a G++ compile command?

By default, GCC compiles C++-code for gnu++98, which is a fancy way of saying the C++98 standard plus lots of gnu extenstions.

You use -std=??? to say to the compiler what standard it should follow.

Don't omit -pedantic though, or it will squint on standards-conformance.

The options you could choose:

standard          with gnu extensions

c++98 gnu++98
c++03 gnu++03
c++11 (c++0x) gnu++11 (gnu++0x)
c++14 (c++1y) gnu++14 (gnu++1y)

Coming up:

c++1z             gnu++1z (Planned for release sometime in 2017, might even make it.)

GCC manual: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Standards.html#Standards

Also, ask for full warnings, so add -Wall -Wextra.

There are preprocessor-defines for making the library include additional checks:

  • _GLIBCXX_CONCEPT_CHECKS to add additional compile-time-checks for some templates prerequisites. Beware that those checks don't actually always do what they should, and are thus deprecated.
  • _GLIBCXX_DEBUG. Enable the libraries debug-mode. This has considerable runtime-overhead.
  • _GLIBCXX_DEBUG_PEDANTIC Same as above, but checks against the standards requirements instead of only against the implementations.

What is the purpose of using -pedantic in the GCC/G++ compiler?

GCC compilers always try to compile your program if this is at all possible. However, in some
cases, the C and C++ standards specify that certain extensions are forbidden. Conforming compilers
such as GCC or g++ must issue a diagnostic when these extensions are encountered.

For example, the GCC compiler’s -pedantic option causes GCC to issue warnings in such cases. Using the stricter -pedantic-errors option converts such diagnostic warnings into errors that will cause compilation to fail at such points. Only those non-ISO constructs that are required to be flagged by a conforming compiler will generate warnings or errors.

When should Flask.g be used?

Advanced Flask Patterns, as linked by Markus, explains some of the changes to g in 0.10:

  • g now lives in the application context.
  • Every request pushes a new application context, wiping the old one, so g can still be used to set flags per-request without change to code.
  • The application context is popped after teardown_request is called. (Armin's presentation explains this is because things like creating DB connections are tasks which setup the environment for the request, and should not be handled inside before_request and after_request)

What is the purpose and use of **kwargs?

You can use **kwargs to let your functions take an arbitrary number of keyword arguments ("kwargs" means "keyword arguments"):

>>> def print_keyword_args(**kwargs):
... # kwargs is a dict of the keyword args passed to the function
... for key, value in kwargs.iteritems():
... print "%s = %s" % (key, value)
...
>>> print_keyword_args(first_name="John", last_name="Doe")
first_name = John
last_name = Doe

You can also use the **kwargs syntax when calling functions by constructing a dictionary of keyword arguments and passing it to your function:

>>> kwargs = {'first_name': 'Bobby', 'last_name': 'Smith'}
>>> print_keyword_args(**kwargs)
first_name = Bobby
last_name = Smith

The Python Tutorial contains a good explanation of how it works, along with some nice examples.

Python 3 update

For Python 3, instead of iteritems(), use items()

What's the point of naming function expressions if you can't really reference them by the names you give them?

Oh, but you can reference them by that name. Those names just only exist inside the scope of the function.

var f = function g() {    // In here, you can use `g` (or `f`) to reference the function    return typeof g;};
console.log( typeof g );// It only exists as `f` hereconsole.log( f() );

How to get Mid point of g tag in svg using javascript

You can get the bounding box of the <g> element by getting a reference to it and calling the function getBBox().

var  bbox = document.getElementById("object_7").getBBox();

Note however that this is the union of all the bounding boxes of the group's children. If the group has a transform, it is not reflected in the bbox value. If you are adding elements to the group, this is probably the one you want.

If you want the bounds of the object in screen space, then you can get the group element's transform and apply it to the centre point you have calculated.

var  ctm = document.getElementById("object_7").getCTM()

// Calculate the centre of the group
var cx = bbox.x + bbox.width/2;
var cy = bbox.y + bbox.height/2;

// Transform cx,cy by the group's transform
var pt = document.getElementById("mysvg").createSVGPoint();
pt.x = cx;
pt.y = cy;
pt = pt.matrixTransform(ctm);

// centre point in screen coordinates is in pt.x and pt.y

Demo here

test algorithm to decide if point is inside area

For your specific problem (quadrilateral - convex), you can do the following:

1) calculate the equations for the 4 sides

2) calculate the intersection of a vertical line which has G on it with each line

3) if you find an even number of intersections, then it is outside

4) if you find an odd number of intersections, then it is inside

5) be careful at the endpoint intersections

6) be careful if G is on one of the sides



Related Topics



Leave a reply



Submit