Set the matrix's elements from an array. If the argument passed is a vector, the resulting matrix will be a single column.
333518
function(els) {
            	var i, j, elements = els.elements || els;
            	if (typeof(elements[0][0]) != 'undefined') {
            	    i = elements.length;
            	    this.elements = [];
            	    while (i--) {
            		j = elements[i].length;
            		this.elements[i] = [];
            		while (j--) {
            		    this.elements[i][j] = elements[i][j];
            		}
            	    }
            	    return this;
            	}
            	var n = elements.length;
            	this.elements = [];
            	for (i = 0; i < n; i++) {
            	    this.elements.push([elements[i]]);
            	}
            	return this;
                }
971023
public void setRow(int i, Vector row) {
        if (columns != row.length()) {
            fail("Wrong vector length: " + row.length() + ". Should be: " + columns + ".");
        }

        for (int j = 0; j < row.length(); j++) {
            set(i, j, row.get(j));
        }
    }
286616
public void set( ZMatrixD1 b )
    {
        if( numRows != b.numRows || numCols != b.numCols ) {
            throw new MatrixDimensionException("The two matrices do not have compatible shapes.");
        }

        int dataLength = b.getDataLength();

        System.arraycopy(b.data, 0, this.data, 0, dataLength);
    }
338983
public static Last[][] setScoreVector(int x, int xb, int yb, int ye, int gop, int gep, int[] subs,
			boolean storing, int[][][] scores, int[] xyMax, int score) {
		Last[][] pointers;
		ensureScoringMatrixColumn(x, storing, scores);
		if (x == xb) {
			pointers = new Last[ye + 1][scores[0][0].length];
		} else {
			pointers = new Last[ye + 1][];
			pointers[0] = new Last[scores[0][0].length];
			for (int y = 1; y < scores[0].length; y++) {
				pointers[y] = setScorePoint(x, y, gop, gep, subs[y], scores);
				for (int z = 0; z < scores[0][0].length; z++) {
					if (scores[x][y][z] <= 0) {
						scores[x][y][z] = 0;
						pointers[y][z] = null;
					}
				}
				if (scores[x][y][0] > score) {
					xyMax[0] = x;
					xyMax[1] = y;
					score = scores[x][y][0];
				}
			}
		}
		return pointers;
	}
989915
public static void setMatrix(final double[][] m1, final int[] r, final int c0, final int c1, final double[][] m2) {
    assert c0 <= c1 : ERR_INVALID_RANGE;
    assert c1 <= m1[0].length : ERR_MATRIX_DIMENSIONS;
    for(int i = 0; i < r.length; i++) {
      System.arraycopy(m2[i], 0, m1[r[i]], c0, c1 - c0);
    }
  }
625225
function matrix(rows, columns, values) {
    // console.log(values);
    const res = [];
    let row = [];
    let real;
    values.forEach((v, i) => {
        if (i % 2 == 0) {
            real = v;
        } else {
            row.push({
                real: real,
                imag: v
            });
            if ((i + 1) / 2 % columns == 0) {
                res.push(row);
                row = [];
            }
        }
    });
    return res;
}
576669
function flatten(matrix) {
    const res = [];

    // If the given matrix is not a matrix but a scalar.
    if (!Array.isArray(matrix)) {
        matrix = [
            [matrix]
        ];
    }

    matrix.forEach((row) => {
        // If the given matrix is a vector.
        if (!Array.isArray(row)) {
            row = [row];
        }

        row.forEach((elem) => {
            res.push(elem.real);
            res.push(elem.imag);
        });
    });
    return res;
}
85138
public function setMatrix()
    {
        if (func_num_args() > 0) {
            $args = func_get_args();
            $match = implode(',', array_map('gettype', $args));
 
            switch ($match) {
        case 'integer,integer,object':
          $M = is_a($args[2], 'Matrix') ? $args[2] : trigger_error(ArgumentTypeException, ERROR);
          $i0 = (($args[0] + $M->m) <= $this->m) ? $args[0] : trigger_error(ArgumentBoundsException, ERROR);
          $j0 = (($args[1] + $M->n) <= $this->n) ? $args[1] : trigger_error(ArgumentBoundsException, ERROR);
 
          for ($i = $i0; $i < $i0 + $M->m; $i++) {
              for ($j = $j0; $j < $j0 + $M->n; $j++) {
                  $this->A[$i][$j] = $M->get($i - $i0, $j - $j0);
              }
          }
 
          break;
 
        case 'integer,integer,array':
          $M = new Matrix($args[2]);
          $i0 = (($args[0] + $M->m) <= $this->m) ? $args[0] : trigger_error(ArgumentBoundsException, ERROR);
          $j0 = (($args[1] + $M->n) <= $this->n) ? $args[1] : trigger_error(ArgumentBoundsException, ERROR);
 
          for ($i = $i0; $i < $i0 + $M->m; $i++) {
              for ($j = $j0; $j < $j0 + $M->n; $j++) {
                  $this->A[$i][$j] = $M->get($i - $i0, $j - $j0);
              }
          }
 
          break;
 
        default:
          trigger_error(PolymorphicArgumentException, ERROR);
          break;
      }
        } else {
            trigger_error(PolymorphicArgumentException, ERROR);
        }
    }
788184
public void setRow(int i, double[] array, int offset)
    {
        int n = cols;
        for (int j=0;j<n;j++)
        {
            set(i, j, array[j+offset]);
        }
    }
1240852
public static void byRow(Matrix m) {
        for (int i = 0; i < m.rows(); ++i) {
            double rowSum = 0;
            for (int j = 0; j < m.columns(); ++j)
                rowSum += m.get(i,j);

            // Skip row whose sume is zero.
            if (rowSum == 0) 
                continue;
            for (int j = 0; j < m.columns(); ++j)
                m.set(i,j, m.get(i,j) / rowSum);
        }
    }
273375
public static void setCol(final double[][] m1, final int c, final double[] column) {
    assert column.length == m1.length : ERR_DIMENSIONS;
    for(int i = 0; i < m1.length; i++) {
      m1[i][c] = column[i];
    }
  }
367170
public static Basic2DMatrix from1DArray(int rows, int columns, double[] array) {
        double[][] array2D = new double[rows][columns];

        for (int i = 0; i < rows; i++) {
            System.arraycopy(array, i * columns, array2D[i], 0, columns);
        }

        return new Basic2DMatrix(array2D);
    }
1146464
public Matrix4d set(Vector4d col0, Vector4d col1, Vector4d col2, Vector4d col3) {
        this.m00 = col0.x;
        this.m01 = col0.y;
        this.m02 = col0.z;
        this.m03 = col0.w;
        this.m10 = col1.x;
        this.m11 = col1.y;
        this.m12 = col1.z;
        this.m13 = col1.w;
        this.m20 = col2.x;
        this.m21 = col2.y;
        this.m22 = col2.z;
        this.m23 = col2.w;
        this.m30 = col3.x;
        this.m31 = col3.y;
        this.m32 = col3.z;
        this.m33 = col3.w;
        this.properties = 0;
        return this;
    }
706741
public void set(int i, int j, DoubleMatrix B)
    {
        int m = B.rows();
        int n = B.columns();
        for (int ii = 0; ii < m; ii++)
        {
            for (int jj = 0; jj < n; jj++)
            {
                set(i+ii, j+jj, B.get(ii, jj));
            }
        }
    }
615456
function(matrix) {
    var M = matrix.elements || matrix;
    if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; }
    // this.columns should equal matrix.rows
    return (this.elements[0].length == M.length);
  }
1258208
public static <T extends DoubleVector> Matrix asMatrix(List<T> vectors) {
        return new ListMatrix<T>(vectors);
    }
1176573
def _vector(x, type='row'):
    """"""
    if isinstance(x, (list, tuple)):
        x = np.array(x, dtype=np.float32)
    elif not isinstance(x, np.ndarray):
        x = np.array([x], dtype=np.float32)
    assert x.ndim == 1
    if type == 'column':
        x = x[:, None]
    return x