Reads a coordinate matrix. First data array contains real entries, and
the second contains imaginary entries
773131
public void readCoordinate(int[] row, int[] column, double[] dataR,
            double[] dataI) throws IOException {
        int size = row.length;
        if (size != column.length || size != dataR.length
                || size != dataI.length)
            throw new IllegalArgumentException(
                    "All arrays must be of the same size");
        for (int i = 0; i < size; ++i) {
            row[i] = getInt();
            column[i] = getInt();
            dataR[i] = getDouble();
            dataI[i] = getDouble();
        }
    }
849880
def read_entry(self):
    
    if len(self.bedarray) <= self.curr_ind: return None
    val = self.bedarray[self.curr_ind]
    self.curr_ind += 1
    return val
961440
def xy_reading_order(e1, e2):
    
    b1 = e1.bbox
    b2 = e2.bbox
    if round(b1[x0]) == round(b2[x0]):
        return float_cmp(b1[y0], b2[y0])
    return float_cmp(b1[x0], b2[x0])
164347
public CMatrixRMaj readCDRM(int numRows, int numCols) throws IOException {

        CMatrixRMaj A = new CMatrixRMaj(numRows,numCols);

        int wordsCol = numCols*2;

        for( int i = 0; i < numRows; i++ ) {
            List<String> words = extractWords();
            if( words == null )
                throw new IOException("Too few rows found. expected "+numRows+" actual "+i);

            if( words.size() != wordsCol )
                throw new IOException("Unexpected number of words in column. Found "+words.size()+" expected "+wordsCol);
            for( int j = 0; j < wordsCol; j += 2 ) {

                float real = Float.parseFloat(words.get(j));
                float imaginary = Float.parseFloat(words.get(j+1));

                A.set(i, j, real, imaginary);
            }
        }

        return A;
    }
1299717
public void mul(Complex a, IMatrix result) {
        if ((result.rows != rows) || (result.columns != columns)) result.reshape(rows, columns);

        int i, j;
        for (i = 0; i < rows; i++)
            for (j = 0; j < columns; j++) {
                result.realmatrix[i][j] = realmatrix[i][j] * a.real - imagmatrix[i][j] * a.imag;
                result.imagmatrix[i][j] = realmatrix[i][j] * a.imag + imagmatrix[i][j] * a.real;
            }
    }
45083
def expand_array(data,
                 scans,
                 c_align,
                 c_exp,
                 scan_size=16,
                 tpz_size=16,
                 nties=200,
                 track_offset=0.5,
                 scan_offset=0.5):
    """"""
    nties = np.asscalar(nties)
    tpz_size = np.asscalar(tpz_size)
    s_scan, s_track = da.meshgrid(np.arange(nties * tpz_size),
                                  np.arange(scans * scan_size))
    s_track = (s_track.reshape(scans, scan_size, nties, tpz_size) % scan_size +
               track_offset) / scan_size
    s_scan = (s_scan.reshape(scans, scan_size, nties, tpz_size) % tpz_size +
              scan_offset) / tpz_size

    a_scan = s_scan + s_scan * (1 - s_scan) * c_exp + s_track * (
        1 - s_track) * c_align
    a_track = s_track

    data_a = data[:scans * 2:2, np.newaxis, :-1, np.newaxis]
    data_b = data[:scans * 2:2, np.newaxis, 1:, np.newaxis]
    data_c = data[1:scans * 2:2, np.newaxis, 1:, np.newaxis]
    data_d = data[1:scans * 2:2, np.newaxis, :-1, np.newaxis]

    fdata = ((1 - a_track) *
             ((1 - a_scan) * data_a + a_scan * data_b) + a_track * (
                 (1 - a_scan) * data_d + a_scan * data_c))
    return fdata.reshape(scans * scan_size, nties * tpz_size)
571758
def read(self, filename, rowprefix=None, colprefix=None, delim=":"):
        """"""

        self.matrix = scipy.io.mmread(filename)
        with open(filename + ".rownames") as in_handle:
            self.rownames = [x.strip() for x in in_handle]
            if rowprefix:
                self.rownames = [rowprefix + delim + x for x in self.rownames]
        with open(filename + ".colnames") as in_handle:
            self.colnames = [x.strip() for x in in_handle]
            if colprefix:
                self.colnames = [colprefix + delim + x for x in self.colnames]
681798
private static CoordinateArraySequence convertSequence(Coordinate[] cs,int dimension) {        
        for (int i = 0; i < cs.length; i++) { 
            Coordinate coord = cs[i];
            switch (dimension) {
                case 2:
                    coord.z = Double.NaN;
                    cs[i]=coord;
                    break;
                case 3: {
                    double z = coord.z;
                    if (Double.isNaN(z)) {
                        coord.z = 0;
                        cs[i]=coord;
                    }
                    break;
                }                
                default:
                    break;
            }
        }        
        return new CoordinateArraySequence(cs, dimension);        
    }
1203978
public void readArray(float[] data) throws IOException {
        int size = data.length;
        for (int i = 0; i < size; ++i)
            data[i] = getFloat();
    }
1132020
def read_array(self, infile, var_name):
        """"""
        file_handle = self.read_cdf(infile)
        try:
            # return the data array
            return file_handle.variables[var_name][:]
        except KeyError:
            print("Cannot find variable: {0}".format(var_name))
            raise KeyError
827975
def _read_projections(folder, indices):
    """"""
    datasets = []

    # Get the relevant file names
    file_names = sorted([f for f in os.listdir(folder) if f.endswith(".dcm")])

    if len(file_names) == 0:
        raise ValueError('No DICOM files found in {}'.format(folder))

    file_names = file_names[indices]

    data_array = None

    for i, file_name in enumerate(tqdm.tqdm(file_names,
                                            'Loading projection data')):
        # read the file
        dataset = dicom.read_file(folder + '/' + file_name)

        # Get some required data
        rows = dataset.NumberofDetectorRows
        cols = dataset.NumberofDetectorColumns
        hu_factor = dataset.HUCalibrationFactor
        rescale_intercept = dataset.RescaleIntercept
        rescale_slope = dataset.RescaleSlope

        # Load the array as bytes
        proj_array = np.array(np.frombuffer(dataset.PixelData, 'H'),
                              dtype='float32')
        proj_array = proj_array.reshape([rows, cols], order='F').T

        # Rescale array
        proj_array *= rescale_slope
        proj_array += rescale_intercept
        proj_array /= hu_factor

        # Store results
        if data_array is None:
            # We need to load the first dataset before we know the shape
            data_array = np.empty((len(file_names), cols, rows),
                                  dtype='float32')

        data_array[i] = proj_array[:, ::-1]
        datasets.append(dataset)

    return datasets, data_array
226334
private INDArray asMatrix(BytePointer bytes, long length) throws IOException {
        PIXA pixa;
        pixa = pixaReadMemMultipageTiff(bytes, length);
        INDArray data;
        INDArray currentD;
        INDArrayIndex[] index = null;
        switch (this.multiPageMode) {
            case MINIBATCH:
                data = Nd4j.create(pixa.n(), 1, pixa.pix(0).h(), pixa.pix(0).w());
                break;
            case CHANNELS:
                data = Nd4j.create(1, pixa.n(), pixa.pix(0).h(), pixa.pix(0).w());
                break;
            case FIRST:
                data = Nd4j.create(1, 1, pixa.pix(0).h(), pixa.pix(0).w());
                PIX pix = pixa.pix(0);
                currentD = asMatrix(convert(pix));
                pixDestroy(pix);
                index = new INDArrayIndex[]{NDArrayIndex.point(0), NDArrayIndex.point(0),NDArrayIndex.all(),NDArrayIndex.all()};
                data.put(index , currentD.get(NDArrayIndex.all(), NDArrayIndex.all(),NDArrayIndex.all()));
                return data;
            default: throw new UnsupportedOperationException("Unsupported MultiPageMode: " + multiPageMode);
        }
        for (int i = 0; i < pixa.n(); i++) {
            PIX pix = pixa.pix(i);
            currentD = asMatrix(convert(pix));
            pixDestroy(pix);
            //TODO to change when 16-bit image is supported
            switch (this.multiPageMode) {
                case MINIBATCH:
                    index = new INDArrayIndex[]{NDArrayIndex.point(i), NDArrayIndex.all(),NDArrayIndex.all(),NDArrayIndex.all()};
                    break;
                case CHANNELS:
                    index = new INDArrayIndex[]{NDArrayIndex.all(), NDArrayIndex.point(i),NDArrayIndex.all(),NDArrayIndex.all()};
                    break;
                default: throw new UnsupportedOperationException("Unsupported MultiPageMode: " + multiPageMode);
            }
            data.put(index , currentD.get(NDArrayIndex.all(), NDArrayIndex.all(),NDArrayIndex.all()));
        }

        return data;
    }
1020372
private void readCoordinate() throws IOException {
        for( int i = 0; i < inputDimension; i++ ) {
            if (i <= 1) {
                ordValues[i] = precisionModel.makePrecise(dis.readDouble());
            } else {
                ordValues[i] = dis.readDouble();
            }

        }
    }
412239
function _Matrix(numRows, numColumns, data) {
  if(!Number.isInteger(numRows))
    throw new TypeError("/numRows/ must be an integer.");
  if(!Number.isInteger(numColumns))
      throw new TypeError("/numColumns/ must be an integer.");

  var _values;
  var _numValues = numRows * numColumns;
  if (!data || data === undefined)
    _values = [];
  else if (!util.isNumberArray(data))
    throw new TypeError('Invalid values for vector.');
  else
    _values = data;

  // Make sure the matrix has numRows * numColumns values
  if (_values.length < _numValues) {
    var zeros = Array(_numValues - _values.length).fill(0);
    _values = _values.concat(zeros);
  } else if (_values.length > _numValues) {
    _values = _values.slice(0, _numValues);
  }

  var size = {"rows": numRows, "columns": numColumns};
  readonly(this, "size", size);
  readonly(this, "values", _values);
  readonly(this, "rows", _getRows(this));
  readonly(this, "columns", _getColumns(this));
}
1200943
def toArray(self):
        
        A = np.zeros((self.numRows, self.numCols), dtype=np.float64, order='F')
        for k in xrange(self.colPtrs.size - 1):
            startptr = self.colPtrs[k]
            endptr = self.colPtrs[k + 1]
            if self.isTransposed:
                A[k, self.rowIndices[startptr:endptr]] = self.values[startptr:endptr]
            else:
                A[self.rowIndices[startptr:endptr], k] = self.values[startptr:endptr]
        return A
215138
def c_float_array(data):
    """"""
    if is_1d_list(data):
        data = np.array(data, copy=False)
    if is_numpy_1d_array(data):
        data = convert_from_sliced_object(data)
        assert data.flags.c_contiguous
        if data.dtype == np.float32:
            ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
            type_data = C_API_DTYPE_FLOAT32
        elif data.dtype == np.float64:
            ptr_data = data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))
            type_data = C_API_DTYPE_FLOAT64
        else:
            raise TypeError("Expected np.float32 or np.float64, met type({})"
                            .format(data.dtype))
    else:
        raise TypeError("Unknown type({})".format(type(data).__name__))
    return (ptr_data, type_data, data)
234844
public MatrixSize readMatrixSize(MatrixInfo info) throws IOException {
        // Always read the matrix size
        int numRows = getInt(), numColumns = getInt();

        // For coordinate matrices we also read the number of entries
        if (info.isDense())
            return new MatrixSize(numRows, numColumns, info);
        else {
            int numEntries = getInt();
            return new MatrixSize(numRows, numColumns, numEntries);
        }
    }