0001: /*
0002: * Licensed to the Apache Software Foundation (ASF) under one or more
0003: * contributor license agreements. See the NOTICE file distributed with
0004: * this work for additional information regarding copyright ownership.
0005: * The ASF licenses this file to You under the Apache License, Version 2.0
0006: * (the "License"); you may not use this file except in compliance with
0007: * the License. You may obtain a copy of the License at
0008: *
0009: * http://www.apache.org/licenses/LICENSE-2.0
0010: *
0011: * Unless required by applicable law or agreed to in writing, software
0012: * distributed under the License is distributed on an "AS IS" BASIS,
0013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014: * See the License for the specific language governing permissions and
0015: * limitations under the License.
0016: */
0017: /**
0018: * @author Igor V. Stolyarov
0019: * @version $Revision$
0020: */package java.awt.image;
0021:
0022: import java.awt.image.DataBuffer;
0023: import java.awt.image.DataBufferDouble;
0024: import junit.framework.TestCase;
0025:
0026: public class DataBufferDoubleTest extends TestCase {
0027:
0028: DataBufferDouble db1, db2, db3, db4, db5, db6;
0029: int numBanks = 4;
0030: int arraySize = 20;
0031: int size = 10;
0032:
0033: @Override
0034: protected void setUp() throws Exception {
0035: super .setUp();
0036: double dataArrays[][] = new double[numBanks][];
0037: for (int i = 0; i < numBanks; i++) {
0038: dataArrays[i] = new double[arraySize];
0039: }
0040:
0041: double dataArray[] = new double[arraySize];
0042: int offsets[] = new int[numBanks];
0043: for (int i = 0; i < numBanks; i++) {
0044: offsets[i] = i;
0045: }
0046:
0047: db1 = new DataBufferDouble(dataArrays, size);
0048: db2 = new DataBufferDouble(dataArrays, size, offsets);
0049: db3 = new DataBufferDouble(dataArray, size);
0050: db4 = new DataBufferDouble(dataArray, size, numBanks);
0051: db5 = new DataBufferDouble(size);
0052: db6 = new DataBufferDouble(size, numBanks);
0053: }
0054:
0055: public DataBufferDoubleTest(String name) {
0056: super (name);
0057: }
0058:
0059: public final void testGetDataType() {
0060: assertEquals(DataBuffer.TYPE_DOUBLE, db1.getDataType());
0061: assertEquals(DataBuffer.TYPE_DOUBLE, db2.getDataType());
0062: assertEquals(DataBuffer.TYPE_DOUBLE, db3.getDataType());
0063: assertEquals(DataBuffer.TYPE_DOUBLE, db4.getDataType());
0064: assertEquals(DataBuffer.TYPE_DOUBLE, db5.getDataType());
0065: assertEquals(DataBuffer.TYPE_DOUBLE, db6.getDataType());
0066: }
0067:
0068: public final void testGetDataTypeSize() {
0069: assertEquals(64, DataBuffer.getDataTypeSize(db1.getDataType()));
0070: assertEquals(64, DataBuffer.getDataTypeSize(db2.getDataType()));
0071: assertEquals(64, DataBuffer.getDataTypeSize(db3.getDataType()));
0072: assertEquals(64, DataBuffer.getDataTypeSize(db4.getDataType()));
0073: assertEquals(64, DataBuffer.getDataTypeSize(db5.getDataType()));
0074: assertEquals(64, DataBuffer.getDataTypeSize(db6.getDataType()));
0075: }
0076:
0077: public final void testGetNumBanks() {
0078: assertEquals(numBanks, db1.getNumBanks());
0079: assertEquals(numBanks, db2.getNumBanks());
0080: assertEquals(1, db3.getNumBanks());
0081: assertEquals(1, db4.getNumBanks());
0082: assertEquals(1, db5.getNumBanks());
0083: assertEquals(numBanks, db6.getNumBanks());
0084: }
0085:
0086: public final void testGetSize() {
0087: assertEquals(size, db1.getSize());
0088: assertEquals(size, db2.getSize());
0089: assertEquals(size, db3.getSize());
0090: assertEquals(size, db4.getSize());
0091: assertEquals(size, db5.getSize());
0092: assertEquals(size, db6.getSize());
0093: }
0094:
0095: public final void testGetOffset() {
0096: assertEquals(0, db1.getOffset());
0097: assertEquals(0, db2.getOffset());
0098: assertEquals(0, db3.getOffset());
0099: assertEquals(numBanks, db4.getOffset());
0100: assertEquals(0, db5.getOffset());
0101: assertEquals(0, db6.getOffset());
0102: }
0103:
0104: public final void testGetOffsets() {
0105: int offsets[];
0106:
0107: offsets = db1.getOffsets();
0108: for (int i = 0; i < db1.getNumBanks(); i++) {
0109: assertEquals(0, offsets[i]);
0110: }
0111:
0112: offsets = db2.getOffsets();
0113: for (int i = 0; i < db2.getNumBanks(); i++) {
0114: assertEquals(i, offsets[i]);
0115: }
0116:
0117: offsets = db3.getOffsets();
0118: for (int i = 0; i < db3.getNumBanks(); i++) {
0119: assertEquals(0, offsets[i]);
0120: }
0121:
0122: offsets = db4.getOffsets();
0123: for (int i = 0; i < db4.getNumBanks(); i++) {
0124: assertEquals(numBanks, offsets[i]);
0125: }
0126:
0127: offsets = db5.getOffsets();
0128: for (int i = 0; i < db5.getNumBanks(); i++) {
0129: assertEquals(0, offsets[i]);
0130: }
0131:
0132: offsets = db6.getOffsets();
0133: for (int i = 0; i < db6.getNumBanks(); i++) {
0134: assertEquals(0, offsets[i]);
0135: }
0136: }
0137:
0138: public final void testGetBankData() {
0139: double bankData[][];
0140:
0141: bankData = db1.getBankData();
0142: assertEquals(numBanks, bankData.length);
0143:
0144: bankData = db2.getBankData();
0145: assertEquals(numBanks, bankData.length);
0146:
0147: bankData = db3.getBankData();
0148: assertEquals(1, bankData.length);
0149:
0150: bankData = db4.getBankData();
0151: assertEquals(1, bankData.length);
0152:
0153: bankData = db5.getBankData();
0154: assertEquals(1, bankData.length);
0155:
0156: bankData = db6.getBankData();
0157: assertEquals(numBanks, bankData.length);
0158:
0159: }
0160:
0161: public final void testGetData() {
0162: double data[];
0163:
0164: data = db1.getData();
0165: assertEquals(arraySize, data.length);
0166:
0167: data = db2.getData();
0168: assertEquals(arraySize, data.length);
0169:
0170: data = db3.getData();
0171: assertEquals(arraySize, data.length);
0172:
0173: data = db4.getData();
0174: assertEquals(arraySize, data.length);
0175:
0176: data = db5.getData();
0177: assertEquals(size, data.length);
0178:
0179: data = db6.getData();
0180: assertEquals(size, data.length);
0181: }
0182:
0183: public final void testGetDataBank() {
0184: double data[];
0185:
0186: for (int i = 0; i < db1.getNumBanks(); i++) {
0187: data = db1.getData(i);
0188: assertEquals(arraySize, data.length);
0189: }
0190:
0191: for (int i = 0; i < db2.getNumBanks(); i++) {
0192: data = db2.getData(i);
0193: assertEquals(arraySize, data.length);
0194: }
0195:
0196: for (int i = 0; i < db3.getNumBanks(); i++) {
0197: data = db3.getData(i);
0198: assertEquals(arraySize, data.length);
0199: }
0200:
0201: for (int i = 0; i < db4.getNumBanks(); i++) {
0202: data = db4.getData(i);
0203: assertEquals(arraySize, data.length);
0204: }
0205:
0206: for (int i = 0; i < db5.getNumBanks(); i++) {
0207: data = db5.getData(i);
0208: assertEquals(size, data.length);
0209: }
0210:
0211: for (int i = 0; i < db6.getNumBanks(); i++) {
0212: data = db6.getData(i);
0213: assertEquals(size, data.length);
0214: }
0215: }
0216:
0217: public final void testSetElemBank() {
0218: double data[];
0219: int offsets[];
0220:
0221: for (int i = 0; i < db1.getNumBanks(); i++) {
0222: for (int j = 0; j < db1.getSize(); j++) {
0223: db1.setElem(i, j, j);
0224: }
0225: }
0226: offsets = db1.getOffsets();
0227: for (int i = 0; i < db1.getNumBanks(); i++) {
0228: data = db1.getData(i);
0229: for (int j = 0; j < size; j++) {
0230: assertEquals(j, data[offsets[i] + j], 0);
0231: }
0232: }
0233:
0234: for (int i = 0; i < db2.getNumBanks(); i++) {
0235: for (int j = 0; j < db2.getSize(); j++) {
0236: db2.setElem(i, j, j);
0237: }
0238: }
0239: offsets = db2.getOffsets();
0240: for (int i = 0; i < db2.getNumBanks(); i++) {
0241: data = db2.getData(i);
0242: for (int j = 0; j < size; j++) {
0243: assertEquals(j, data[offsets[i] + j], 0);
0244: }
0245: }
0246:
0247: for (int i = 0; i < db3.getNumBanks(); i++) {
0248: for (int j = 0; j < db3.getSize(); j++) {
0249: db3.setElem(i, j, j);
0250: }
0251: }
0252: offsets = db3.getOffsets();
0253: for (int i = 0; i < db3.getNumBanks(); i++) {
0254: data = db3.getData(i);
0255: for (int j = 0; j < size; j++) {
0256: assertEquals(j, data[offsets[i] + j], 0);
0257: }
0258: }
0259:
0260: for (int i = 0; i < db4.getNumBanks(); i++) {
0261: for (int j = 0; j < db4.getSize(); j++) {
0262: db4.setElem(i, j, j);
0263: }
0264: }
0265: offsets = db4.getOffsets();
0266: for (int i = 0; i < db4.getNumBanks(); i++) {
0267: data = db4.getData(i);
0268: for (int j = 0; j < size; j++) {
0269: assertEquals(j, data[offsets[i] + j], 0);
0270: }
0271: }
0272:
0273: for (int i = 0; i < db5.getNumBanks(); i++) {
0274: for (int j = 0; j < db5.getSize(); j++) {
0275: db5.setElem(i, j, j);
0276: }
0277: }
0278: offsets = db5.getOffsets();
0279: for (int i = 0; i < db5.getNumBanks(); i++) {
0280: data = db5.getData(i);
0281: for (int j = 0; j < size; j++) {
0282: assertEquals(j, data[offsets[i] + j], 0);
0283: }
0284: }
0285:
0286: for (int i = 0; i < db6.getNumBanks(); i++) {
0287: for (int j = 0; j < db6.getSize(); j++) {
0288: db6.setElem(i, j, j);
0289: }
0290: }
0291: offsets = db6.getOffsets();
0292: for (int i = 0; i < db6.getNumBanks(); i++) {
0293: data = db6.getData(i);
0294: for (int j = 0; j < size; j++) {
0295: assertEquals(j, data[offsets[i] + j], 0);
0296: }
0297: }
0298:
0299: }
0300:
0301: public final void testSetElem() {
0302: double data[];
0303: int offset;
0304:
0305: for (int i = 0; i < size; i++) {
0306: db1.setElem(i, i);
0307: }
0308: data = db1.getData();
0309: offset = db1.getOffset();
0310: for (int i = 0; i < size; i++) {
0311: assertEquals(i, data[offset + i], 0);
0312: }
0313:
0314: for (int i = 0; i < size; i++) {
0315: db2.setElem(i, i);
0316: }
0317: data = db2.getData();
0318: offset = db2.getOffset();
0319: for (int i = 0; i < size; i++) {
0320: assertEquals(i, data[offset + i], 0);
0321: }
0322:
0323: for (int i = 0; i < size; i++) {
0324: db3.setElem(i, i);
0325: }
0326: data = db3.getData();
0327: offset = db3.getOffset();
0328: for (int i = 0; i < size; i++) {
0329: assertEquals(i, data[offset + i], 0);
0330: }
0331:
0332: for (int i = 0; i < size; i++) {
0333: db4.setElem(i, i);
0334: }
0335: data = db4.getData();
0336: offset = db4.getOffset();
0337: for (int i = 0; i < size; i++) {
0338: assertEquals(i, data[offset + i], 0);
0339: }
0340:
0341: for (int i = 0; i < size; i++) {
0342: db5.setElem(i, i);
0343: }
0344: data = db5.getData();
0345: offset = db5.getOffset();
0346: for (int i = 0; i < size; i++) {
0347: assertEquals(i, data[offset + i], 0);
0348: }
0349:
0350: for (int i = 0; i < size; i++) {
0351: db6.setElem(i, i);
0352: }
0353: data = db6.getData();
0354: offset = db6.getOffset();
0355: for (int i = 0; i < size; i++) {
0356: assertEquals(i, data[offset + i], 0);
0357: }
0358: }
0359:
0360: public final void testGetElemBank() {
0361: double data[];
0362: int offsets[];
0363:
0364: offsets = db1.getOffsets();
0365: for (int i = 0; i < db1.getNumBanks(); i++) {
0366: data = db1.getData(i);
0367: for (int j = 0; j < size; j++) {
0368: data[offsets[i] + j] = j;
0369: }
0370: }
0371: for (int i = 0; i < db1.getNumBanks(); i++) {
0372: for (int j = 0; j < size; j++) {
0373: assertEquals(j, db1.getElem(i, j));
0374: }
0375: }
0376:
0377: offsets = db2.getOffsets();
0378: for (int i = 0; i < db2.getNumBanks(); i++) {
0379: data = db2.getData(i);
0380: for (int j = 0; j < size; j++) {
0381: data[offsets[i] + j] = j;
0382: }
0383: }
0384: for (int i = 0; i < db2.getNumBanks(); i++) {
0385: for (int j = 0; j < size; j++) {
0386: assertEquals(j, db2.getElem(i, j));
0387: }
0388: }
0389:
0390: offsets = db3.getOffsets();
0391: for (int i = 0; i < db3.getNumBanks(); i++) {
0392: data = db3.getData(i);
0393: for (int j = 0; j < size; j++) {
0394: data[offsets[i] + j] = j;
0395: }
0396: }
0397: for (int i = 0; i < db3.getNumBanks(); i++) {
0398: for (int j = 0; j < size; j++) {
0399: assertEquals(j, db3.getElem(i, j));
0400: }
0401: }
0402:
0403: offsets = db4.getOffsets();
0404: for (int i = 0; i < db4.getNumBanks(); i++) {
0405: data = db4.getData(i);
0406: for (int j = 0; j < size; j++) {
0407: data[offsets[i] + j] = j;
0408: }
0409: }
0410: for (int i = 0; i < db4.getNumBanks(); i++) {
0411: for (int j = 0; j < size; j++) {
0412: assertEquals(j, db4.getElem(i, j));
0413: }
0414: }
0415:
0416: offsets = db5.getOffsets();
0417: for (int i = 0; i < db5.getNumBanks(); i++) {
0418: data = db5.getData(i);
0419: for (int j = 0; j < size; j++) {
0420: data[offsets[i] + j] = j;
0421: }
0422: }
0423: for (int i = 0; i < db5.getNumBanks(); i++) {
0424: for (int j = 0; j < size; j++) {
0425: assertEquals(j, db5.getElem(i, j));
0426: }
0427: }
0428:
0429: offsets = db6.getOffsets();
0430: for (int i = 0; i < db6.getNumBanks(); i++) {
0431: data = db6.getData(i);
0432: for (int j = 0; j < size; j++) {
0433: data[offsets[i] + j] = j;
0434: }
0435: }
0436: for (int i = 0; i < db6.getNumBanks(); i++) {
0437: for (int j = 0; j < size; j++) {
0438: assertEquals(j, db6.getElem(i, j));
0439: }
0440: }
0441: }
0442:
0443: public final void testGetElem() {
0444: double data[];
0445: int offset;
0446:
0447: data = db1.getData();
0448: offset = db1.getOffset();
0449: for (int i = 0; i < size; i++) {
0450: data[offset + i] = i;
0451: }
0452: for (int i = 0; i < size; i++) {
0453: assertEquals(i, db1.getElem(i));
0454: }
0455:
0456: data = db2.getData();
0457: offset = db2.getOffset();
0458: for (int i = 0; i < size; i++) {
0459: data[offset + i] = i;
0460: }
0461: for (int i = 0; i < size; i++) {
0462: assertEquals(i, db2.getElem(i));
0463: }
0464:
0465: data = db3.getData();
0466: offset = db3.getOffset();
0467: for (int i = 0; i < size; i++) {
0468: data[offset + i] = i;
0469: }
0470: for (int i = 0; i < size; i++) {
0471: assertEquals(i, db3.getElem(i));
0472: }
0473:
0474: data = db4.getData();
0475: offset = db4.getOffset();
0476: for (int i = 0; i < size; i++) {
0477: data[offset + i] = i;
0478: }
0479: for (int i = 0; i < size; i++) {
0480: assertEquals(i, db4.getElem(i));
0481: }
0482:
0483: data = db5.getData();
0484: offset = db5.getOffset();
0485: for (int i = 0; i < size; i++) {
0486: data[offset + i] = i;
0487: }
0488: for (int i = 0; i < size; i++) {
0489: assertEquals(i, db5.getElem(i));
0490: }
0491:
0492: data = db6.getData();
0493: offset = db6.getOffset();
0494: for (int i = 0; i < size; i++) {
0495: data[offset + i] = i;
0496: }
0497: for (int i = 0; i < size; i++) {
0498: assertEquals(i, db6.getElem(i));
0499: }
0500: }
0501:
0502: public final void testSetElemFloatBank() {
0503: double data[];
0504: int offsets[];
0505:
0506: for (int i = 0; i < db1.getNumBanks(); i++) {
0507: for (int j = 0; j < db1.getSize(); j++) {
0508: db1.setElemFloat(i, j, j);
0509: }
0510: }
0511: offsets = db1.getOffsets();
0512: for (int i = 0; i < db1.getNumBanks(); i++) {
0513: data = db1.getData(i);
0514: for (int j = 0; j < size; j++) {
0515: assertEquals(j, data[offsets[i] + j], 0);
0516: }
0517: }
0518:
0519: for (int i = 0; i < db2.getNumBanks(); i++) {
0520: for (int j = 0; j < db2.getSize(); j++) {
0521: db2.setElemFloat(i, j, j);
0522: }
0523: }
0524: offsets = db2.getOffsets();
0525: for (int i = 0; i < db2.getNumBanks(); i++) {
0526: data = db2.getData(i);
0527: for (int j = 0; j < size; j++) {
0528: assertEquals(j, data[offsets[i] + j], 0);
0529: }
0530: }
0531:
0532: for (int i = 0; i < db3.getNumBanks(); i++) {
0533: for (int j = 0; j < db3.getSize(); j++) {
0534: db3.setElemFloat(i, j, j);
0535: }
0536: }
0537: offsets = db3.getOffsets();
0538: for (int i = 0; i < db3.getNumBanks(); i++) {
0539: data = db3.getData(i);
0540: for (int j = 0; j < size; j++) {
0541: assertEquals(j, data[offsets[i] + j], 0);
0542: }
0543: }
0544:
0545: for (int i = 0; i < db4.getNumBanks(); i++) {
0546: for (int j = 0; j < db4.getSize(); j++) {
0547: db4.setElemFloat(i, j, j);
0548: }
0549: }
0550: offsets = db4.getOffsets();
0551: for (int i = 0; i < db4.getNumBanks(); i++) {
0552: data = db4.getData(i);
0553: for (int j = 0; j < size; j++) {
0554: assertEquals(j, data[offsets[i] + j], 0);
0555: }
0556: }
0557:
0558: for (int i = 0; i < db5.getNumBanks(); i++) {
0559: for (int j = 0; j < db5.getSize(); j++) {
0560: db5.setElemFloat(i, j, j);
0561: }
0562: }
0563: offsets = db5.getOffsets();
0564: for (int i = 0; i < db5.getNumBanks(); i++) {
0565: data = db5.getData(i);
0566: for (int j = 0; j < size; j++) {
0567: assertEquals(j, data[offsets[i] + j], 0);
0568: }
0569: }
0570:
0571: for (int i = 0; i < db6.getNumBanks(); i++) {
0572: for (int j = 0; j < db6.getSize(); j++) {
0573: db6.setElemFloat(i, j, j);
0574: }
0575: }
0576: offsets = db6.getOffsets();
0577: for (int i = 0; i < db6.getNumBanks(); i++) {
0578: data = db6.getData(i);
0579: for (int j = 0; j < size; j++) {
0580: assertEquals(j, data[offsets[i] + j], 0);
0581: }
0582: }
0583:
0584: }
0585:
0586: public final void testSetElemFloat() {
0587: double data[];
0588: int offset;
0589:
0590: for (int i = 0; i < size; i++) {
0591: db1.setElemFloat(i, i);
0592: }
0593: data = db1.getData();
0594: offset = db1.getOffset();
0595: for (int i = 0; i < size; i++) {
0596: assertEquals(i, data[offset + i], 0);
0597: }
0598:
0599: for (int i = 0; i < size; i++) {
0600: db2.setElemFloat(i, i);
0601: }
0602: data = db2.getData();
0603: offset = db2.getOffset();
0604: for (int i = 0; i < size; i++) {
0605: assertEquals(i, data[offset + i], 0);
0606: }
0607:
0608: for (int i = 0; i < size; i++) {
0609: db3.setElemFloat(i, i);
0610: }
0611: data = db3.getData();
0612: offset = db3.getOffset();
0613: for (int i = 0; i < size; i++) {
0614: assertEquals(i, data[offset + i], 0);
0615: }
0616:
0617: for (int i = 0; i < size; i++) {
0618: db4.setElemFloat(i, i);
0619: }
0620: data = db4.getData();
0621: offset = db4.getOffset();
0622: for (int i = 0; i < size; i++) {
0623: assertEquals(i, data[offset + i], 0);
0624: }
0625:
0626: for (int i = 0; i < size; i++) {
0627: db5.setElemFloat(i, i);
0628: }
0629: data = db5.getData();
0630: offset = db5.getOffset();
0631: for (int i = 0; i < size; i++) {
0632: assertEquals(i, data[offset + i], 0);
0633: }
0634:
0635: for (int i = 0; i < size; i++) {
0636: db6.setElemFloat(i, i);
0637: }
0638: data = db6.getData();
0639: offset = db6.getOffset();
0640: for (int i = 0; i < size; i++) {
0641: assertEquals(i, data[offset + i], 0);
0642: }
0643: }
0644:
0645: public final void testGetElemFloatBank() {
0646: double data[];
0647: int offsets[];
0648:
0649: offsets = db1.getOffsets();
0650: for (int i = 0; i < db1.getNumBanks(); i++) {
0651: data = db1.getData(i);
0652: for (int j = 0; j < size; j++) {
0653: data[offsets[i] + j] = j;
0654: }
0655: }
0656: for (int i = 0; i < db1.getNumBanks(); i++) {
0657: for (int j = 0; j < size; j++) {
0658: assertEquals(j, db1.getElemFloat(i, j), 0f);
0659: }
0660: }
0661:
0662: offsets = db2.getOffsets();
0663: for (int i = 0; i < db2.getNumBanks(); i++) {
0664: data = db2.getData(i);
0665: for (int j = 0; j < size; j++) {
0666: data[offsets[i] + j] = j;
0667: }
0668: }
0669: for (int i = 0; i < db2.getNumBanks(); i++) {
0670: for (int j = 0; j < size; j++) {
0671: assertEquals(j, db2.getElem(i, j), 0f);
0672: }
0673: }
0674:
0675: offsets = db3.getOffsets();
0676: for (int i = 0; i < db3.getNumBanks(); i++) {
0677: data = db3.getData(i);
0678: for (int j = 0; j < size; j++) {
0679: data[offsets[i] + j] = j;
0680: }
0681: }
0682: for (int i = 0; i < db3.getNumBanks(); i++) {
0683: for (int j = 0; j < size; j++) {
0684: assertEquals(j, db3.getElemFloat(i, j), 0f);
0685: }
0686: }
0687:
0688: offsets = db4.getOffsets();
0689: for (int i = 0; i < db4.getNumBanks(); i++) {
0690: data = db4.getData(i);
0691: for (int j = 0; j < size; j++) {
0692: data[offsets[i] + j] = j;
0693: }
0694: }
0695: for (int i = 0; i < db4.getNumBanks(); i++) {
0696: for (int j = 0; j < size; j++) {
0697: assertEquals(j, db4.getElemFloat(i, j), 0f);
0698: }
0699: }
0700:
0701: offsets = db5.getOffsets();
0702: for (int i = 0; i < db5.getNumBanks(); i++) {
0703: data = db5.getData(i);
0704: for (int j = 0; j < size; j++) {
0705: data[offsets[i] + j] = j;
0706: }
0707: }
0708: for (int i = 0; i < db5.getNumBanks(); i++) {
0709: for (int j = 0; j < size; j++) {
0710: assertEquals(j, db5.getElemFloat(i, j), 0f);
0711: }
0712: }
0713:
0714: offsets = db6.getOffsets();
0715: for (int i = 0; i < db6.getNumBanks(); i++) {
0716: data = db6.getData(i);
0717: for (int j = 0; j < size; j++) {
0718: data[offsets[i] + j] = j;
0719: }
0720: }
0721: for (int i = 0; i < db6.getNumBanks(); i++) {
0722: for (int j = 0; j < size; j++) {
0723: assertEquals(j, db6.getElemFloat(i, j), 0f);
0724: }
0725: }
0726: }
0727:
0728: public final void testGetElemFloat() {
0729: double data[];
0730: int offset;
0731:
0732: data = db1.getData();
0733: offset = db1.getOffset();
0734: for (int i = 0; i < size; i++) {
0735: data[offset + i] = i;
0736: }
0737: for (int i = 0; i < size; i++) {
0738: assertEquals(i, db1.getElemFloat(i), 0f);
0739: }
0740:
0741: data = db2.getData();
0742: offset = db2.getOffset();
0743: for (int i = 0; i < size; i++) {
0744: data[offset + i] = i;
0745: }
0746: for (int i = 0; i < size; i++) {
0747: assertEquals(i, db2.getElemFloat(i), 0f);
0748: }
0749:
0750: data = db3.getData();
0751: offset = db3.getOffset();
0752: for (int i = 0; i < size; i++) {
0753: data[offset + i] = i;
0754: }
0755: for (int i = 0; i < size; i++) {
0756: assertEquals(i, db3.getElemFloat(i), 0f);
0757: }
0758:
0759: data = db4.getData();
0760: offset = db4.getOffset();
0761: for (int i = 0; i < size; i++) {
0762: data[offset + i] = i;
0763: }
0764: for (int i = 0; i < size; i++) {
0765: assertEquals(i, db4.getElemFloat(i), 0f);
0766: }
0767:
0768: data = db5.getData();
0769: offset = db5.getOffset();
0770: for (int i = 0; i < size; i++) {
0771: data[offset + i] = i;
0772: }
0773: for (int i = 0; i < size; i++) {
0774: assertEquals(i, db5.getElemFloat(i), 0f);
0775: }
0776:
0777: data = db6.getData();
0778: offset = db6.getOffset();
0779: for (int i = 0; i < size; i++) {
0780: data[offset + i] = i;
0781: }
0782: for (int i = 0; i < size; i++) {
0783: assertEquals(i, db6.getElemFloat(i), 0f);
0784: }
0785: }
0786:
0787: public final void testSetElemDoubleBank() {
0788: double data[];
0789: int offsets[];
0790:
0791: for (int i = 0; i < db1.getNumBanks(); i++) {
0792: for (int j = 0; j < db1.getSize(); j++) {
0793: db1.setElemDouble(i, j, j);
0794: }
0795: }
0796: offsets = db1.getOffsets();
0797: for (int i = 0; i < db1.getNumBanks(); i++) {
0798: data = db1.getData(i);
0799: for (int j = 0; j < size; j++) {
0800: assertEquals(j, data[offsets[i] + j], 0);
0801: }
0802: }
0803:
0804: for (int i = 0; i < db2.getNumBanks(); i++) {
0805: for (int j = 0; j < db2.getSize(); j++) {
0806: db2.setElemDouble(i, j, j);
0807: }
0808: }
0809: offsets = db2.getOffsets();
0810: for (int i = 0; i < db2.getNumBanks(); i++) {
0811: data = db2.getData(i);
0812: for (int j = 0; j < size; j++) {
0813: assertEquals(j, data[offsets[i] + j], 0);
0814: }
0815: }
0816:
0817: for (int i = 0; i < db3.getNumBanks(); i++) {
0818: for (int j = 0; j < db3.getSize(); j++) {
0819: db3.setElemDouble(i, j, j);
0820: }
0821: }
0822: offsets = db3.getOffsets();
0823: for (int i = 0; i < db3.getNumBanks(); i++) {
0824: data = db3.getData(i);
0825: for (int j = 0; j < size; j++) {
0826: assertEquals(j, data[offsets[i] + j], 0);
0827: }
0828: }
0829:
0830: for (int i = 0; i < db4.getNumBanks(); i++) {
0831: for (int j = 0; j < db4.getSize(); j++) {
0832: db4.setElemDouble(i, j, j);
0833: }
0834: }
0835: offsets = db4.getOffsets();
0836: for (int i = 0; i < db4.getNumBanks(); i++) {
0837: data = db4.getData(i);
0838: for (int j = 0; j < size; j++) {
0839: assertEquals(j, data[offsets[i] + j], 0);
0840: }
0841: }
0842:
0843: for (int i = 0; i < db5.getNumBanks(); i++) {
0844: for (int j = 0; j < db5.getSize(); j++) {
0845: db5.setElemDouble(i, j, j);
0846: }
0847: }
0848: offsets = db5.getOffsets();
0849: for (int i = 0; i < db5.getNumBanks(); i++) {
0850: data = db5.getData(i);
0851: for (int j = 0; j < size; j++) {
0852: assertEquals(j, data[offsets[i] + j], 0);
0853: }
0854: }
0855:
0856: for (int i = 0; i < db6.getNumBanks(); i++) {
0857: for (int j = 0; j < db6.getSize(); j++) {
0858: db6.setElemDouble(i, j, j);
0859: }
0860: }
0861: offsets = db6.getOffsets();
0862: for (int i = 0; i < db6.getNumBanks(); i++) {
0863: data = db6.getData(i);
0864: for (int j = 0; j < size; j++) {
0865: assertEquals(j, data[offsets[i] + j], 0);
0866: }
0867: }
0868:
0869: }
0870:
0871: public final void testSetElemDouble() {
0872: double data[];
0873: int offset;
0874:
0875: for (int i = 0; i < size; i++) {
0876: db1.setElemDouble(i, i);
0877: }
0878: data = db1.getData();
0879: offset = db1.getOffset();
0880: for (int i = 0; i < size; i++) {
0881: assertEquals(i, data[offset + i], 0);
0882: }
0883:
0884: for (int i = 0; i < size; i++) {
0885: db2.setElemDouble(i, i);
0886: }
0887: data = db2.getData();
0888: offset = db2.getOffset();
0889: for (int i = 0; i < size; i++) {
0890: assertEquals(i, data[offset + i], 0);
0891: }
0892:
0893: for (int i = 0; i < size; i++) {
0894: db3.setElemDouble(i, i);
0895: }
0896: data = db3.getData();
0897: offset = db3.getOffset();
0898: for (int i = 0; i < size; i++) {
0899: assertEquals(i, data[offset + i], 0);
0900: }
0901:
0902: for (int i = 0; i < size; i++) {
0903: db4.setElemDouble(i, i);
0904: }
0905: data = db4.getData();
0906: offset = db4.getOffset();
0907: for (int i = 0; i < size; i++) {
0908: assertEquals(i, data[offset + i], 0);
0909: }
0910:
0911: for (int i = 0; i < size; i++) {
0912: db5.setElemDouble(i, i);
0913: }
0914: data = db5.getData();
0915: offset = db5.getOffset();
0916: for (int i = 0; i < size; i++) {
0917: assertEquals(i, data[offset + i], 0);
0918: }
0919:
0920: for (int i = 0; i < size; i++) {
0921: db6.setElemDouble(i, i);
0922: }
0923: data = db6.getData();
0924: offset = db6.getOffset();
0925: for (int i = 0; i < size; i++) {
0926: assertEquals(i, data[offset + i], 0);
0927: }
0928: }
0929:
0930: public final void testGetElemDoubleBank() {
0931: double data[];
0932: int offsets[];
0933:
0934: offsets = db1.getOffsets();
0935: for (int i = 0; i < db1.getNumBanks(); i++) {
0936: data = db1.getData(i);
0937: for (int j = 0; j < size; j++) {
0938: data[offsets[i] + j] = j;
0939: }
0940: }
0941: for (int i = 0; i < db1.getNumBanks(); i++) {
0942: for (int j = 0; j < size; j++) {
0943: assertEquals(j, db1.getElemDouble(i, j), 0);
0944: }
0945: }
0946:
0947: offsets = db2.getOffsets();
0948: for (int i = 0; i < db2.getNumBanks(); i++) {
0949: data = db2.getData(i);
0950: for (int j = 0; j < size; j++) {
0951: data[offsets[i] + j] = j;
0952: }
0953: }
0954: for (int i = 0; i < db2.getNumBanks(); i++) {
0955: for (int j = 0; j < size; j++) {
0956: assertEquals(j, db2.getElemDouble(i, j), 0);
0957: }
0958: }
0959:
0960: offsets = db3.getOffsets();
0961: for (int i = 0; i < db3.getNumBanks(); i++) {
0962: data = db3.getData(i);
0963: for (int j = 0; j < size; j++) {
0964: data[offsets[i] + j] = j;
0965: }
0966: }
0967: for (int i = 0; i < db3.getNumBanks(); i++) {
0968: for (int j = 0; j < size; j++) {
0969: assertEquals(j, db3.getElemDouble(i, j), 0);
0970: }
0971: }
0972:
0973: offsets = db4.getOffsets();
0974: for (int i = 0; i < db4.getNumBanks(); i++) {
0975: data = db4.getData(i);
0976: for (int j = 0; j < size; j++) {
0977: data[offsets[i] + j] = j;
0978: }
0979: }
0980: for (int i = 0; i < db4.getNumBanks(); i++) {
0981: for (int j = 0; j < size; j++) {
0982: assertEquals(j, db4.getElemDouble(i, j), 0);
0983: }
0984: }
0985:
0986: offsets = db5.getOffsets();
0987: for (int i = 0; i < db5.getNumBanks(); i++) {
0988: data = db5.getData(i);
0989: for (int j = 0; j < size; j++) {
0990: data[offsets[i] + j] = j;
0991: }
0992: }
0993: for (int i = 0; i < db5.getNumBanks(); i++) {
0994: for (int j = 0; j < size; j++) {
0995: assertEquals(j, db5.getElemDouble(i, j), 0);
0996: }
0997: }
0998:
0999: offsets = db6.getOffsets();
1000: for (int i = 0; i < db6.getNumBanks(); i++) {
1001: data = db6.getData(i);
1002: for (int j = 0; j < size; j++) {
1003: data[offsets[i] + j] = j;
1004: }
1005: }
1006: for (int i = 0; i < db6.getNumBanks(); i++) {
1007: for (int j = 0; j < size; j++) {
1008: assertEquals(j, db6.getElemDouble(i, j), 0);
1009: }
1010: }
1011: }
1012:
1013: public final void testGetElemDouble() {
1014: double data[];
1015: int offset;
1016:
1017: data = db1.getData();
1018: offset = db1.getOffset();
1019: for (int i = 0; i < size; i++) {
1020: data[offset + i] = i;
1021: }
1022: for (int i = 0; i < size; i++) {
1023: assertEquals(i, db1.getElemDouble(i), 0);
1024: }
1025:
1026: data = db2.getData();
1027: offset = db2.getOffset();
1028: for (int i = 0; i < size; i++) {
1029: data[offset + i] = i;
1030: }
1031: for (int i = 0; i < size; i++) {
1032: assertEquals(i, db2.getElemDouble(i), 0);
1033: }
1034:
1035: data = db3.getData();
1036: offset = db3.getOffset();
1037: for (int i = 0; i < size; i++) {
1038: data[offset + i] = i;
1039: }
1040: for (int i = 0; i < size; i++) {
1041: assertEquals(i, db3.getElemDouble(i), 0);
1042: }
1043:
1044: data = db4.getData();
1045: offset = db4.getOffset();
1046: for (int i = 0; i < size; i++) {
1047: data[offset + i] = i;
1048: }
1049: for (int i = 0; i < size; i++) {
1050: assertEquals(i, db4.getElemDouble(i), 0);
1051: }
1052:
1053: data = db5.getData();
1054: offset = db5.getOffset();
1055: for (int i = 0; i < size; i++) {
1056: data[offset + i] = i;
1057: }
1058: for (int i = 0; i < size; i++) {
1059: assertEquals(i, db5.getElemDouble(i), 0);
1060: }
1061:
1062: data = db6.getData();
1063: offset = db6.getOffset();
1064: for (int i = 0; i < size; i++) {
1065: data[offset + i] = i;
1066: }
1067: for (int i = 0; i < size; i++) {
1068: assertEquals(i, db6.getElemDouble(i), 0);
1069: }
1070: }
1071:
1072: }
|