Standard_Integer RowNumber = UppR - LowR + 1;
Standard_Integer ColNumber = UppC - LowC + 1;
- Standard_Real** TheAddr = !isAddrAllocated? (Standard_Real**)&AddrBuf :
- (Standard_Real**) Standard::Allocate(RowNumber * sizeof(Standard_Real*));
- Standard_Real* Address;
if(isAllocated)
- Address = (Standard_Real*) Standard::Allocate(RowNumber * ColNumber * sizeof(Standard_Real));
- else
- Address = (Standard_Real*) Addr;
- Address -= LowC;
-
- for (Standard_Integer Index = 0; Index < RowNumber; Index++) {
- TheAddr[Index] = Address;
- Address += ColNumber;
- }
-
- TheAddr -= LowR;
- Addr = (Standard_Address) TheAddr;
+ Addr = (Standard_Real*) Standard::Allocate(RowNumber * ColNumber * sizeof(Standard_Real));
}
math_DoubleTab::math_DoubleTab(const Standard_Integer LowerRow,
const Standard_Integer LowerCol,
const Standard_Integer UpperCol) :
Addr(Buf),
- isAddrAllocated(UpperRow - LowerRow + 1 > CARRAY_LENGTH(AddrBuf)),
isAllocated((UpperRow - LowerRow + 1) * (UpperCol - LowerCol + 1) > CARRAY_LENGTH(Buf)),
LowR(LowerRow),
UppR(UpperRow),
const Standard_Integer LowerCol,
const Standard_Integer UpperCol) :
Addr(Tab),
- isAddrAllocated(UpperRow - LowerRow + 1 > CARRAY_LENGTH(AddrBuf)),
isAllocated(Standard_False),
LowR(LowerRow),
UppR(UpperRow),
void math_DoubleTab::Init(const Standard_Real InitValue)
{
- for (Standard_Integer i = LowR; i <= UppR; i++) {
- for (Standard_Integer j = LowC; j <= UppC; j++) {
- ((Standard_Real**) Addr)[i][j] = InitValue;
- }
+ for (Standard_Integer anIndex = 0; anIndex < (UppR - LowR + 1) * (UppC - LowC + 1); anIndex++)
+ {
+ ((Standard_Real* )Addr)[anIndex] = InitValue;
}
}
math_DoubleTab::math_DoubleTab(const math_DoubleTab& Other) :
Addr(Buf),
- isAddrAllocated(Other.UppR - Other.LowR + 1 > CARRAY_LENGTH(AddrBuf)),
isAllocated((Other.UppR - Other.LowR + 1) *
(Other.UppC - Other.LowC + 1) > CARRAY_LENGTH(Buf)),
LowR(Other.LowR),
UppC(Other.UppC)
{
Allocate();
-
- Standard_Address target = (Standard_Address) &Value(LowR,LowC);
- Standard_Address source = (Standard_Address) &Other.Value(LowR,LowC);
-
- memmove(target,source,
- (int)((UppR - LowR + 1) * (UppC - LowC + 1) * sizeof(Standard_Real)));
-
+ memmove (Addr, Other.Addr, (int)((UppR - LowR + 1) * (UppC - LowC + 1) * sizeof(Standard_Real)));
}
void math_DoubleTab::Free()
{
// free the data
- if(isAllocated) {
- Standard_Address it = (Standard_Address)&Value(LowR,LowC);
- Standard::Free(it);
- }
- // free the pointers
- if(isAddrAllocated) {
- Standard_Address it = (Standard_Address)(((Standard_Real**)Addr) + LowR);
- Standard::Free (it);
+ if(isAllocated)
+ {
+ Standard::Free (Addr);
}
+
Addr = 0;
}
void math_DoubleTab::SetLowerRow(const Standard_Integer LowerRow)
{
- Standard_Real** TheAddr = (Standard_Real**)Addr;
- Addr = (Standard_Address) (TheAddr + LowR - LowerRow);
UppR = UppR - LowR + LowerRow;
LowR = LowerRow;
}
void math_DoubleTab::SetLowerCol(const Standard_Integer LowerCol)
{
- Standard_Real** TheAddr = (Standard_Real**) Addr;
- for (Standard_Integer Index = LowR; Index <= UppR; Index++) {
- TheAddr[Index] = TheAddr[Index] + LowC - LowerCol;
- }
-
UppC = UppC - LowC + LowerCol;
LowC = LowerCol;
}
inline Standard_Real& math_DoubleTab::Value (const Standard_Integer RowIndex,
const Standard_Integer ColIndex) const
{
- return ((Standard_Real**)Addr)[RowIndex][ColIndex];
+ return ((Standard_Real*)Addr)[(UppC - LowC + 1) * (RowIndex - LowR) + (ColIndex - LowC)];
}
inline void math_DoubleTab::Copy(math_DoubleTab& Other)const
{
- memmove((void*)(& Other.Value(Other.LowR,Other.LowC)),
- (void*) (& Value(LowR,LowC)),
- (int)((UppR - LowR + 1) * (UppC - LowC + 1) * sizeof(Standard_Real)));
+ memmove (Other.Addr, Addr, (int)((UppR - LowR + 1) * (UppC - LowC + 1) * sizeof(Standard_Real)));
}