有人能告诉我下面的疯狂循环结构是否可以用更好的方式重写吗?现在它做了我想做的一切。
// xi and yi stand for x and y axis input index
for (int xi = 0; xi < this.inputNumberOfColumnsAlongXAxis; xi++)
{
for (int yi = 0; yi < this.inputNumberOfColumnsAlongYAxis; yi++)
{
InputCell inputCell = new InputCell(xi, yi);
Synapse synapse = new Synapse(inputCell);
// add (inputDataScaleReductionOnXAxis * inputDataScaleReductionOnYAxis)
// number of synapses to a proximalSegment.
for (int x = 0; x < this.numberOfColumnsAlongXAxis; x++)
{
for (int y = 0; y < this.numberOfColumnsAlongYAxis; y++)
{
int inputX =
(int)Math.round(x * inputDataScaleReductionOnXAxis);
int inputY =
(int)Math.round(y * inputDataScaleReductionOnYAxis);
this.columns[(y * this.numberOfColumnsAlongXAxis) + x] =
new Column(this, inputX, inputY, x, y);
// only add the square of synapses directly under the proximal segment
while (xi < this.inputDataScaleReductionOnXAxis * (x + 1))
{
while (yi < this.inputDataScaleReductionOnYAxis * (y + 1))
{
this.getColumn(x, y).getProximalSegment().addSynapse(synapse);
}
}
}
}
}
}