很多比较旧的代码会有如写法

class Foo

{

int Foo::Foo(void);

}

在g++ 4.1以后会报错 extra qualification

直接改为

class Foo

{

int Foo(void);

}

即可

The author`s blog: http://hi.baidu.com/zjugator/blog/item/77bb6cec02bee22163d09f7d.html

很多比较旧的代码会有如写法

class Foo

{

int Foo::Foo(void);

}

在g++ 4.1以后会报错 extra qualification

直接改为

class Foo

{

int Foo(void);

}

即可

The author`s blog: http://hi.baidu.com/zjugator/blog/item/77bb6cec02bee22163d09f7d.html

gcc App.o -o App -L/usr/local/lib -L/usr/lib -L/usr/lib64 -DNO_SDL_MAIN -lz -lzip -lzipd -ldl -lX11 -lXext -lpthread -lGLU -lGL -ljpeg -lpng -lavformat -lavcodec -lavutil -lavdevice -lSDL -lG3D -lGLG3D -lG3Dd -lGLG3Dd -lm

这是GCC编译G3D例子starter的输入！看上去确实吓人，在刚接触GCC的时候，这个东西几乎让我疯狂了！在抓狂了一周后，今天凌晨终于解决了编译和链接的问题！现在谈谈这两天的感觉。希望抛砖引玉！

1. Linux下的library 和header都是搜索式的，比如有两个路径，/usr/local/lib和/lib，里面分别有一个叫G3D的header，当你使用linux下的编译器时，比如gcc，他会先搜索一个路径，在搜索另一个路径，先到先的，这个顺序是取决于你的输入顺序或设置的，一些新安装的库可能需要你对输入做一定的排序才能正确使用。G3D的安装过程中，我就犯了一个这样的错误，/usr/local/lib首先搜索，其下的libzipd.a没有更新，所以不管我怎么修改配置，重新编译，更换版本都无济于事，最后的解决办法很简单，要么删除/usr/local/lib下的库或者将新编译的库文件设置到较高的搜索优先级。Windows下就相对简单了，他们是登记式的，或者是更细化的搜索，你只要在注册表，环境变量或编译器中登记要使用的类库，虽然这个过程linux也有，但windows是没有固定的/lib和/include目录的，就是没有默认搜索，所以windows这个过程更直观一些。

2.“Undefined reference to .......” in link step. 这个问题通常因为library没有找到，比如你安装library的路径没有被编译器搜索，而include却被搜索到了，所以就出现了编译成功而链接出错！这里更需要注意的是gcc与window的错误信息是有区别的，在windows上，undefind refernce 肯定出现在编译阶段，链接阶段会说undefind symbol...如果你习惯了vc的错误信息，很容易把gcc link的错误当作编译的错误，所以不管你怎么改，都是不会有效的......

3.gcc的库是搜索式的，所以你不需要定义库的位置，只需要定义库的名字，如果你的安装路径不是默认的，你还需要设定一个搜索路径，gcc会一个接一个的搜索，当然，这里也会有谁先谁后的问题！library的命名方式是lib开头，然后是库的名字，最后的后缀是lib。gcc输入这是-l开头，紧跟着是lib的名字。比如，我向gcc传入 -lG3D， 在../lib中，他应该叫做libG3D.lib。最后用-lm表示library输入结束，而且要在最后！-L说明搜索的路径，FIFS！

这是GCC编译G3D例子starter的输入！看上去确实吓人，在刚接触GCC的时候，这个东西几乎让我疯狂了！在抓狂了一周后，今天凌晨终于解决了编译和链接的问题！现在谈谈这两天的感觉。希望抛砖引玉！

1. Linux下的library 和header都是搜索式的，比如有两个路径，/usr/local/lib和/lib，里面分别有一个叫G3D的header，当你使用linux下的编译器时，比如gcc，他会先搜索一个路径，在搜索另一个路径，先到先的，这个顺序是取决于你的输入顺序或设置的，一些新安装的库可能需要你对输入做一定的排序才能正确使用。G3D的安装过程中，我就犯了一个这样的错误，/usr/local/lib首先搜索，其下的libzipd.a没有更新，所以不管我怎么修改配置，重新编译，更换版本都无济于事，最后的解决办法很简单，要么删除/usr/local/lib下的库或者将新编译的库文件设置到较高的搜索优先级。Windows下就相对简单了，他们是登记式的，或者是更细化的搜索，你只要在注册表，环境变量或编译器中登记要使用的类库，虽然这个过程linux也有，但windows是没有固定的/lib和/include目录的，就是没有默认搜索，所以windows这个过程更直观一些。

2.“Undefined reference to .......” in link step. 这个问题通常因为library没有找到，比如你安装library的路径没有被编译器搜索，而include却被搜索到了，所以就出现了编译成功而链接出错！这里更需要注意的是gcc与window的错误信息是有区别的，在windows上，undefind refernce 肯定出现在编译阶段，链接阶段会说undefind symbol...如果你习惯了vc的错误信息，很容易把gcc link的错误当作编译的错误，所以不管你怎么改，都是不会有效的......

3.gcc的库是搜索式的，所以你不需要定义库的位置，只需要定义库的名字，如果你的安装路径不是默认的，你还需要设定一个搜索路径，gcc会一个接一个的搜索，当然，这里也会有谁先谁后的问题！library的命名方式是lib开头，然后是库的名字，最后的后缀是lib。gcc输入这是-l开头，紧跟着是lib的名字。比如，我向gcc传入 -lG3D， 在../lib中，他应该叫做libG3D.lib。最后用-lm表示library输入结束，而且要在最后！-L说明搜索的路径，FIFS！

Suppose you are in a science class and you receive these instructions:
Find the temperature of the water (in degrees Celsius) at the times 1, 2, 3, 4, and 5 seconds after you have applied heat to the container. Conduct your experiment carefully. Graph each data point with time on the The data from the experiment looks like this when charted and graphed:
This is a common problem with experimental sciences because the data points that we measure seldom fall on a straight line. Therefore, scientists try to find an approximation. In this case, they would try to find the line that best fits the data in some sense. The first problem is to define "best fit." It is convenient to define an error as a distance from the actual value of You have just read a lot of new information, so let's illustrate the concepts with our example. We have the graph of the data above. Now we need to guess which line best fits our data. If we assume that the first two points are correct and choose the line that goes through them, we get the line
If we choose the line that goes through the points when The sum of the squares of the error is 18. That is a better fit, but can we do even better? Let's try the line that is half way between these two lines. The equation would be
A line in slope-intercept form looks like
In general, we cannot solve this system because the system is usually inconsistent because it is overdetermined. In other words, we have more equations than unknowns (the unknowns are the two variables,
The normal equations will give us the "best fit" line (or curve) every time according to the way we defined "best fit." The proof of this is at the end of this chapter. Let's try applying the normal equations to our system. First, we multiply so that we have a system that we can solve.
The sum of the squares of the error is 2.7. This is a great improvement over our guesses and we know that we cannot do any better. In general, if we have
, and The ellipse marks (written as or tell you to continue in the same pattern. What if we are told that our data is not supposed to fit a straight line, but instead falls in the shape of a parabola? Consider the following data from another experiment:
We can find the curve that best fits our data in a similar manner. The general equation for a parabola is
These coefficients indicate that the curve we want is Let's graph this curve and fill in our chart:
We find that the sum of the squared errors is Using our definition of least squares "best fit," you will not be able to find a parabola that fits the data better than this one. In general, to find the parabola that best fits the data, you use the normal equations
Notice that the normal equations used to find the best fit line and the best fit parabola have the same form. Do you think that we could expand this to higher degree polynomials? Yes, we can. In general, we use the normal equations X^{T}Xc = X^{T}y with
where x. Remember that the degree is the highest power of the variable in your equation. A line is a first degree polynomial and a parabola is a second degree polynomial. ^{m}If we can find the best fit curve for any degree polynomial, why don't we always use a higher degree polynomial and fit the data better? After all, if we have If you notice, we said that we usually fit a curve so that we can predict what would happen between our data points. Predicting an outcome between data points is called
If we extrapolate back several years, this young man was over two and a half feet tall when he was born. According to this model, he will never stop growing, so he will be 8 feet 4 inches tall by the time he is 30 and almost 14 feet tall by the time he is 60. Do you think that this is an accurate prediction? If the temperature at the airport on the 4th of July was in the 90's for two years in a row, would it be reasonable to predict that the temperature in January between those years was also in the 90's? No, it would not. We have two problems with this model. One problem is that we only have 2 data points. You can always find a line that fits the two points, but there is no reason to believe that the relationship between the day of the year and the temperature is a linear relationship. Also, we didn't take into account other factors that could affect our model such as the pattern of the seasons. These are problems that can arise when you model a situation. When we start modeling situations and using least squares to make predictions, we are entering the world of statistics. That means that we must think about what the data represents rather than just apply the normal equations. There are many interesting applications of statistics that you can explore in another course. However, using matrices, you already know one way to find a "best fit" curve for your data. |

Subscribe to:
Posts (Atom)