?? particle.cpp
字號:
// PARTICLE.cpp: implementation of the PARTICLE class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SBGA.h"
#include "PARTICLE.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//微粒構(gòu)造函數(shù)
PARTICLE::PARTICLE() //空構(gòu)造函數(shù)
{
X = 0; V = 0; XBest = 0; Dim = 0;
}
PARTICLE::PARTICLE(int n) //維數(shù)為參數(shù)的構(gòu)造函數(shù)
{
Dim = n;
X = new double[Dim];
V = new double[Dim];
XBest = new double[Dim];
}
//微粒析構(gòu)函數(shù)
PARTICLE::~PARTICLE()
{
if(Dim)
{
delete []X;
delete []V;
delete XBest;
}
}
//設(shè)置微粒的維數(shù)
void PARTICLE::SetDim(int d)
{
if(X) delete []X;
if(V) delete []V;
if(XBest) delete []XBest;
Dim = d;
X = new double[Dim];
V = new double[Dim];
XBest = new double[Dim];
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -