Tag Archives: c++

C++矩阵库比较

同化系统中要大量使用矩阵类,现在使用的是之前有我们自己发展的纯C++的一个矩阵类,而后又引入了IT++类的支持,现在回头来看,又有很多新的C++矩阵类库发展出来,并且有很好的特性。今天就用了几个测试代码在我的DELL T7400工作站进行了测试,主要比较的是我们自己的矩阵类、armadillo、IT++(参考文献中还有和其他矩阵类的比较)。

Posted in Program | Tagged , , , | Leave a comment

C++ 0X将在2011年发布

经过多年的反复,新版本的C++标准即将发布,将重新命名为C++ 2011。 reference: 1. http://www.osnews.com/story/24578/ISO_Finalizes_C_Update 2. http://www.cio.com.au/article/381241/iso_finalizes_c_update/

Posted in Computer | Tagged | Leave a comment

cout float的显示问题

在c++,使用cout直接显示float类型的数据,在不同系统上显示方式可能有所不同。 测试代码: #include <iostream> using namespace std; int main() { float t=0.000000277; cout<<t<<endl; return 0; } 在LINUX上: 2.77e-07 而在WINDOWS上结果如下: 2.77e-007

Posted in Linux, Program | Tagged , , , | Leave a comment

ubuntu下使用netcdf库

netcdf自身带了C++接口,可是按照例子,怎么也连接不了,最后发现是要加参数: g++ -lnetcdf_c++ -lnetcdf -o test *.cpp

Posted in Linux, Program | Tagged , , | Leave a comment

c++的类模板

c++的类模板中有一些要注意的地方: 1、除非编译器实现了export关键字,否则将模板成员函数放置在一个独立的实现文件中将无法运行。(在GCC中,就是无法连接,编译可以通过) 因为模板不是函数,它们不能单独编译。模板必须与特定的模板实例化请求一起使用。 2、在类模板的操作符重载的友元函数中,要先声明,如

Posted in Program | Tagged , , , | Leave a comment

C# 2008:From Novice to Professional

Apress.Beginning.C.Sharp.2008.From.Novice.to.Professional.Nov.2007 书名:《C# 2008:From Novice to Professional》 作者:Christian Gross (Author) 出版商:Apress 发行日期:2007年11月 语言:英语 ISBN-10/ISBN-13:1590598695/978-1590598696 http://www.amazon.com/exec/obidos/tg/detail/-/1590598695/ 粗看了一遍,介绍的比较全面,感觉不是很深入。

Posted in Program | Tagged , , | Leave a comment

生成UUID/GUID

php的生成办法: <?php class System { function currentTimeMillis() { list($usec, $sec) = explode(” “,microtime()); return $sec.substr($usec, 2, 3); } } class NetAddress { var $Name = ‘localhost’; var $IP = ’127.0.0.1′; function getLocalHost() // static { $address = new NetAddress(); $address->Name … Continue reading

Posted in Program | Tagged , , , , | 1 Comment

c++中如何创建目录

c++中读写文件直接使用fstream就可以操作,但如何对目录进行操作? 一番搜索下来后,发现std库并不能处理目录的操作,需要使用额外库来进行操作。 windows平台下: #include <windows.h> CreateDirectory (char *DirName, SECURITY_ATTRIBUTES Attribs); linux平台下: #include <sys/stat.h> mkdir (const char *path, mode_t mode); 一个例子: #include <sys/types.h> #include <sys/stat.h> int status; … status = mkdir(“/home/cnd/mod1″, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 还可以使用boost的跨平台方案: #include “boost/filesystem.hpp” … Continue reading

Posted in Program | Tagged , , | Leave a comment

c++中的string转换

如何转换string到其他类型?如何从其他类型转换到string? 代码1:toString template <class T> std::string toString(const T& a) { std::ostringstream ost; ost << a; return ost.str(); } 代码2:fromString template<typename T>T fromString( const std::string& s) { std::istringstream is(s); T t; is >> t; return t; } 使用方法: int d = … Continue reading

Posted in Program | Tagged , , | Leave a comment

使用FileChooserDialog打开多文件

单文件比较简单, 看到这个函数的原型是这样的: Glib::SListHandle<Glib::ustring> Gtk::FileChooser::get_filenames ( ) const 因此,就以为要使用这样的变量来进行声明: Glib::SListHandle<Glib::ustring> filenames =dialog.get_filenames(); for(int i=0;i<filenames.size();i++) { //Notice that this is a std::string, not a Glib::ustring. //std::string filename = dialog.get_filename(); std::cout << “File selected: ” << filenames[i] << std::endl; } 结果发现编译不通过,再仔细看看,Glib::SListHandle并没有重载[]操作符。 再网络上搜索后发现有人和我的问题相同: That … Continue reading

Posted in Program | Tagged , , | 2 Comments