3 #ifndef __zd_f3d_matrix_hpp
4 #define __zd_f3d_matrix_hpp
9 #include "zqb_macros.h"
10 #include "zd_function3d.hpp"
22 #ifndef __zd_f3d_matrix_global_vars
25 extern int g_iZdF3DMatrixCounter;
28 extern char* g_szZdF3DMatrixOwnType;
63 ZdF3DMatrixPolicy m_eStPolicy;
85 ZdF3DMatrixPolicy ePolicy = Z_F3DM_ALA_C)
86 :
ZqbAutoName(&g_iZdF3DMatrixCounter, g_szZdF3DMatrixOwnType),
87 m_bKnownMM(false), m_eStPolicy(ePolicy),
88 m_pZMatrix(NULL), m_pDetached(NULL)
102 m_X.fOffset = pfXYInfo[0];
103 m_Y.fOffset = pfXYInfo[1];
104 m_X.fStep = pfXYInfo[2];
105 m_Y.fStep = pfXYInfo[3];
109 m_pDetached =
new T[m_X.nCount * m_Y.nCount];
110 m_pZMatrix = m_pDetached;
113 memset(m_pDetached, 0,
sizeof(T) * m_X.nCount * m_Y.nCount);
114 m_fMinMax[0] = m_fMinMax[1] = 0.0;
134 ZdF3DMatrix (
const T* pArray,
int nX,
int nY,
double pfXYInfo[4] = NULL,
135 bool bDetached =
true, ZdF3DMatrixPolicy ePolicy = Z_F3DM_ALA_C)
136 :
ZqbAutoName(&g_iZdF3DMatrixCounter, g_szZdF3DMatrixOwnType),
137 m_pZMatrix(pArray), m_pDetached(NULL),
138 m_bKnownMM(false), m_eStPolicy(ePolicy)
152 m_X.fOffset = pfXYInfo[0];
153 m_Y.fOffset = pfXYInfo[1];
154 m_X.fStep = pfXYInfo[2];
155 m_Y.fStep = pfXYInfo[3];
161 m_pDetached =
new T[m_X.nCount * m_Y.nCount];
164 m_pZMatrix = m_pDetached;
167 memcpy(m_pDetached, pArray,
sizeof(T) * m_X.nCount * m_Y.nCount);
174 delete[] m_pDetached;
183 virtual void setFunc (
int iX,
int iY, T value)
185 if(iX < 0 || iX >=
countX() || iY < 0 || iY >=
countY())
188 if(m_eStPolicy == Z_F3DM_ALA_C)
189 m_pDetached[iX + iY *
countX()] = value;
191 m_pDetached[iY + iX *
countY()] = value;
196 m_fMinMax[0] = ZqbMIN(m_fMinMax[0], (
double)value);
197 m_fMinMax[1] = ZqbMAX(m_fMinMax[1], (
double)value);
221 return m_X.fOffset + m_X.fStep * iX;
227 return m_Y.fOffset + m_Y.fStep * iY;
232 virtual double func (
int iX,
int iY)
234 if(iX < 0 || iX >=
countX() || iY < 0 || iY >=
countY())
237 if(m_eStPolicy == Z_F3DM_ALA_C)
238 return (
double) m_pZMatrix[iX + iY *
countX()];
240 return (
double) m_pZMatrix[iY + iX *
countY()];
260 if(iX < 0 || iX >=
countX() || iY < 0 || iY >=
countY())
334 b[0] = (double) m_fMinMax[0];
335 b[1] = (double) m_fMinMax[1];
344 double fiX = (x - m_X.fOffset) /
argStepX();
345 if(fiX - (
int)fiX < 0.5)
355 double fiY = (y - m_Y.fOffset) /
argStepY();
356 if(fiY - (
int)fiY < 0.5)
370 typedef class ZdF3DMatrix<double> ZdF3DMatrixDouble;
virtual void getFuncBounds(double b[2])
virtual ~ZdF3DMatrix()
Definition: zd_f3d_matrix.hpp:172
ZdF3DMatrix(int nX, int nY, double pfXYInfo[4]=NULL, ZdF3DMatrixPolicy ePolicy=Z_F3DM_ALA_C)
Definition: zd_f3d_matrix.hpp:84
virtual bool isNullFunc(int iX, int iY)
Definition: zd_f3d_matrix.hpp:258
virtual double argStepY()
Definition: zd_f3d_matrix.hpp:274
int nCount
Definition: zd_f3d_matrix.hpp:51
virtual void getArgBoundsX(double b[2])
Definition: zd_f3d_matrix.hpp:282
virtual int countY()
Definition: zd_f3d_matrix.hpp:213
virtual double func(int iX, int iY)
Definition: zd_f3d_matrix.hpp:232
ZdF3DMatrix(const T *pArray, int nX, int nY, double pfXYInfo[4]=NULL, bool bDetached=true, ZdF3DMatrixPolicy ePolicy=Z_F3DM_ALA_C)
Definition: zd_f3d_matrix.hpp:134
virtual void setFunc(int iX, int iY, T value)
Definition: zd_f3d_matrix.hpp:183
double fOffset
Definition: zd_f3d_matrix.hpp:52
Definition: zqb_autoname.hpp:18
virtual double argStepX()
Definition: zd_f3d_matrix.hpp:267
virtual double argX(int iX)
Definition: zd_f3d_matrix.hpp:219
virtual int countX()
Definition: zd_f3d_matrix.hpp:207
virtual int argIndexX(double x)
Definition: zd_f3d_matrix.hpp:342
Definition: zd_f3d_matrix.hpp:45
double fStep
Definition: zd_f3d_matrix.hpp:53
virtual double argY(int iY)
Definition: zd_f3d_matrix.hpp:225
virtual void getArgBoundsY(double b[2])
Definition: zd_f3d_matrix.hpp:302
virtual bool isNullAll()
Definition: zd_f3d_matrix.hpp:251
virtual int argIndexY(double y)
Definition: zd_f3d_matrix.hpp:353
Definition: zd_function3d.hpp:29
virtual void getFuncBounds(double b[2])
Definition: zd_f3d_matrix.hpp:323