Commit 699ddac6 by xiaotong

robust code

parent 7e36dc0b
...@@ -48,9 +48,9 @@ XList NULLList; ...@@ -48,9 +48,9 @@ XList NULLList;
XList::XList() XList::XList()
{ {
mem = NULL; mem = NULL;
maxNum = 0; maxNum = 8;
count = 0; count = 0;
items = NULL; items = new void*[8];
isIntList = false; isIntList = false;
} }
......
...@@ -573,10 +573,11 @@ get the size of a given dimension ...@@ -573,10 +573,11 @@ get the size of a given dimension
int XTensor::GetDim(const int dim) const int XTensor::GetDim(const int dim) const
{ {
CheckNTErrors(dim < order, "dimenision is out of range!"); CheckNTErrors(dim < order, "dimenision is out of range!");
CheckNTErrors(dim >= -order, "dimenision is out of range!");
int d = dim; int d = dim;
if(dim < 0) if(dim < 0)
d = order - 1; d = order + dim;
return dimSize[d]; return dimSize[d];
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论