[問題] 請問數學函式包成class,用static好嗎?
好比有個FT class :
#include <math.h>
#include "mathtool.h"
// mathtool是定義 complex class ,一堆operator overloading
// 裡面含有 typedef double real
#ifndef _FT_H
#define _FT_H
class FT
{
public:
static complex *FFT(int n, complex *y);
static complex *IFFT(int n, complex *f);
static complex *DFT(int n, complex *y);
static complex *IDFT(int n, complex *f);
static complex *DFT(int n, real *y);
static complex *FFT(int n, real *y );
protected:
static void four1(real data[], unsigned long nn, int isign);
} ;
#undef real
#endif
class 外面要用裡面的成員做計算
/*y 是長度為n的 real number array*/
real *f = FT::DFT(n,y);
:
:
不需要先new一個FT,用範圍運算子::即可
那請問設為static 與設為一般member在最計算時有差嗎?
速度/記憶體是否有所不同?
我是完全不知道別人怎包裝這類function的。
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.216.81.152
※ 編輯: Carbontube 來自: 61.216.81.152 (05/16 23:22)
→
05/17 06:11, , 1F
05/17 06:11, 1F
推
05/17 10:28, , 2F
05/17 10:28, 2F
→
05/17 10:28, , 3F
05/17 10:28, 3F
→
05/17 20:59, , 4F
05/17 20:59, 4F
→
05/17 21:00, , 5F
05/17 21:00, 5F
→
05/17 21:00, , 6F
05/17 21:00, 6F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章