Beispiel #1
0
void gsl_vector_free (gsl_vector * v)
{

  if (v->owner)
    {
      gsl_block_free(v->block) ;
    }
  free (v);
}
Beispiel #2
0
int
main (void)
{
  gsl_block * b = gsl_block_alloc (100);
  
  printf ("length of block = %u\n", b->size);
  printf ("block data address = %#x\n", b->data);

  gsl_block_free (b);
  return 0;
}
Beispiel #3
0
/**
	This method	sets the current matrix	to be a	sub-matrix (starting at	(i,j) and ending at	(i+rows, j+cols)
	of the one that	is passed in as	a parameter	- shallow copy only.
*/
void Matrix::setToSubmatrix(const Matrix &a, int i,	int	j, int rows, int cols){
	//we have to first delete the current matrix
//	gsl_matrix_free(this->matrix);
	//and create the shallow copy
//	this->matrix = gsl_matrix_alloc_from_matrix(a.matrix, i, j, rows, cols);
//we'll do it manually to make it faster, and we won't check for the correctness of the input - up to the user to provide good parameters

  if (this->matrix->owner){
      gsl_block_free(this->matrix->block);
  }

  this->matrix->data = a.matrix->data + i * a.matrix->tda + j ;
  this->matrix->size1 = rows;
  this->matrix->size2 = cols;
  this->matrix->tda = a.matrix->tda;
  this->matrix->block = a.matrix->block;
  this->matrix->owner = 0;
}
/**
	This method sets the current vector to be equal to one of the cols of A - shallow column only!
*/
void Vector::setToCol(const Matrix& A, int col, int start, int howManyRows){
	if (this->matrix->owner){
		gsl_block_free(this->matrix->block);
	}

	//make sure that end, if unspecified is equal to the number of columns - i.e. a whole row
	if (howManyRows <= 0)
		howManyRows = A.matrix->size1 - start;

	//this is where it starts
	this->matrix->data = A.matrix->data + start * A.matrix->tda + col ;
	//this vector will have as many rows as the column we're copying has rows
	this->matrix->size1 = howManyRows;
	this->matrix->size2 = 1;
	//set this to 1 - as long as on a row of the matrix, elements are packed (i.e. MULTIPLICITY is 1), then this is fine. 
	this->matrix->tda = A.matrix->tda;
	this->matrix->block = A.matrix->block;
	this->matrix->owner = 0;
}