예제 #1
0
파일: mtx_row.c 프로젝트: Angeldude/pd
static void mtx_row_list(t_matrix *x, t_symbol *s, int argc, t_atom *argv)
{
  if (argc==1){
    t_float f=atom_getfloat(argv);
    t_atom *ap=x->atombuffer+2+(x->current_row-1)*x->col;
    if (x->current_row>x->row){
      post("mtx_row : too high a row is to be set");
      return;
    }
    if (x->current_row){
      int n=x->col;
      while(n--){
	SETFLOAT(ap, f);
	ap++;
      }
    }
    matrix_bang(x);
    return;
  }

  if (argc<x->col){
    post("mtx_row : row length is too small for %dx%d-matrix", x->row, x->col);
    return;
  }
  if (x->current_row>x->row){
    post("mtx_row : too high a row is to be set");
    return;
  }
  if(x->current_row) {memcpy(x->atombuffer+2+(x->current_row-1)*x->col, argv, x->col*sizeof(t_atom));
  }  else {
    int r=x->row;
    while(r--)memcpy(x->atombuffer+2+r*x->col, argv, x->col*sizeof(t_atom));      
  }
  matrix_bang(x);
}
예제 #2
0
static void mtx_col_list(t_matrix *x, t_symbol *s, int argc, t_atom *argv)
{
  if (argc==1) {
    t_float f=atom_getfloat(argv);
    t_atom *ap=x->atombuffer+1+x->current_col;
    if (x->current_col>x->col) {
      pd_error(x, "[mtx_col]: too high a column is to be set");
      return;
    }
    if (x->current_col) {
      int n=x->row;
      while(n--) {
        SETFLOAT(ap, f);
        ap+=x->row+1;
      }
    }
    matrix_bang(x);
    return;
  }

  if (argc<x->row) {
    pd_error(x, "[mtx_col]: column length is too small for %dx%d-matrix", x->row,
         x->col);
    return;
  }
  if (x->current_col>x->col) {
    pd_error(x, "[mtx_col]: too high a column is to be set");
    return;
  }
  if(x->current_col) {
    int r=x->row;
    t_atom *ap=x->atombuffer+1+x->current_col;
    while(r--) {
      SETFLOAT(&ap[(x->row-r-1)*x->col], atom_getfloat(argv++));
    }
  }  else {
    int r=x->row;
    t_atom *ap=x->atombuffer+2;
    while (r--) {
      t_float f=atom_getfloat(argv++);
      int c=x->col;
      while(c--) {
        SETFLOAT(ap, f);
        ap++;
      }
    }
  }
  matrix_bang(x);
}
예제 #3
0
static void mtx_row_matrix(t_matrix *x, t_symbol *s, int argc,
                           t_atom *argv)
{
  if(iemmatrix_check(x, argc, argv, 0))return;
  matrix_matrix2(x, s, argc, argv);
  matrix_bang(x);
}
예제 #4
0
static void mtx_roll_matrix(t_matrix *x, t_symbol *s, int argc,
                            t_atom *argv)
{
  int row, col, colroll;
  t_atom *ap;
  int c;
  if(iemmatrix_check(x, argc, argv, 0))return;
  row=atom_getint(argv++);
  col=atom_getint(argv++);
  colroll = ((int)x->f%col+col)%col;

  adjustsize(x, row, col);
  ap = x->atombuffer+2;

  c=col;
  while(c--) {
    t_atom *in  = argv+col-c-1;
    t_atom *out = ap  +(col-c-1+colroll)%col;
    int r = row;
    while (r--) {
      SETFLOAT(out, atom_getfloat(in));
      out+=col;
      in+=col;
    }

  }

  matrix_bang(x);
}
예제 #5
0
static void mtx_transpose_matrix(t_matrix *x, t_symbol *s, int argc,
                                 t_atom *argv)
{
  int row, col;
  t_atom *ap;
  int r, c;
  if(iemmatrix_check(x, argc, argv, 0))return;
  row=atom_getint(argv+0);
  col=atom_getint(argv+1);
  if (col*row!=x->col*x->row) {
    freebytes(x->atombuffer, (x->col*x->row+2)*sizeof(t_atom));
    x->atombuffer = (t_atom *)getbytes((row*col+2)*sizeof(t_atom));
  }
  ap = x->atombuffer+2;
  setdimen(x, col, row);
  r = row;
  while(r--) {
    c=col;
    while(c--) {
      t_float f = atom_getfloat(argv+2+r*col+c);
      SETFLOAT(ap+c*row+r, f);
    }
  }

  matrix_bang(x);
}
예제 #6
0
static void matrix_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv)
{
  int row, col;
  if(iemmatrix_check(x, argc, argv, 0))return;
  row = atom_getfloat(argv);
  col = atom_getfloat(argv+1);
  matrix_matrix2(x, s, argc, argv);
  matrix_bang(x);
}
예제 #7
0
파일: mtx_row.c 프로젝트: Angeldude/pd
static void mtx_row_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv)
{
  int row, col;
  if (argc<2){    post("matrix : corrupt matrix passed");    return;  }
  row = atom_getfloat(argv);
  col = atom_getfloat(argv+1);
  if ((row<1)||(col<1)){    post("matrix : corrupt matrix passed");    return;  }
  if (row*col > argc-2){    post("matrix: sparse matrices not yet supported : use \"mtx_check\"");    return;  }
  matrix_matrix2(x, s, argc, argv);
  matrix_bang(x);
}
예제 #8
0
static void matrix_list(t_matrix *x, t_symbol *s, int argc, t_atom *argv)
{
  /* like matrix, but without col/row information, so the previous size is kept */
  int row=x->row, col=x->col;
  if(!row*col) {
    pd_error(x, "[matrix]: unknown matrix dimensions");
    return;
  }
  if (argc<row*col) {
    pd_error(x, "[matrix]: sparse matrices not yet supported : use [mtx_check]!");
    return;
  }

  memcpy(x->atombuffer+2, argv, row*col*sizeof(t_atom));
  matrix_bang(x);
}
예제 #9
0
static void mtx_scroll_matrix(t_matrix *x, t_symbol *s, int argc,
                              t_atom *argv)
{
  int row, col, rowscroll;
  if(iemmatrix_check(x, argc, argv, 0))return;

  row=atom_getfloat(argv++);
  col=atom_getfloat(argv++);
  rowscroll = ((int)x->f%row+row)%row;
  adjustsize(x, row, col);

  memcpy(x->atombuffer+2, argv+(row-rowscroll)*col,
         rowscroll*col*sizeof(t_atom));
  memcpy(x->atombuffer+2+rowscroll*col, argv,
         (row-rowscroll)*col*sizeof(t_atom));

  matrix_bang(x);
}
예제 #10
0
static void mtx_resize_matrix(t_matrix *x, t_symbol *s, int argc, t_atom *argv)
{
    int row=atom_getfloat(argv);
    int col=atom_getfloat(argv+1);
    int r = x->current_row, c = x->current_col;
    int R=0, ROW, COL;

    if (argc<2) {
        post("mtx_add: crippled matrix");
        return;
    }
    if ((col<1)||(row<1)) {
        post("mtx_add: invalid dimensions");
        return;
    }
    if (col*row>argc-2) {
        post("sparse matrix not yet supported : use \"mtx_check\"");
        return;
    }

    if (!r)r=row;
    if (!c)c=col;

    if (r==row && c==col) { /* no need to change */
        outlet_anything(x->x_obj.ob_outlet, gensym("matrix"), argc, argv);
        return;
    }

    x->atombuffer=(t_atom *)getbytes((c*r+2)*sizeof(t_atom));
    setdimen(x, r, c);
    matrix_set(x, 0);

    ROW=(r<row)?r:row;
    COL=(c<col)?c:col;
    R=ROW;
    while(R--)memcpy(x->atombuffer+2+(ROW-R-1)*c, argv+2+(ROW-R-1)*col, COL*sizeof(t_atom));

    matrix_bang(x);

    freebytes(x->atombuffer, (c*r+2)*sizeof(t_atom));
}
예제 #11
0
static void matrix_float(t_matrix *x, t_float f)
{
  matrix_set(x, f);
  matrix_bang(x);
}