Index: src/OFDoubleMatrix.h ================================================================== --- src/OFDoubleMatrix.h +++ src/OFDoubleMatrix.h @@ -46,14 +46,17 @@ /** * \brief Creates a new matrix with the specified dimension and data. * * \param rows The number of rows for the matrix * \param columns The number of colums for the matrix + * \param data The first double of the data for the matrix. The data is in the + * format rows-columns. * \return A new autoreleased OFDoubleMatrix */ + matrixWithRows: (size_t)rows - columnsAndData: (size_t)columns, ...; + columns: (size_t)columns + data: (double)data, ...; /** * \brief Initializes the matrix with the specified dimension. * * If the number of rows and columns is equal, the matrix is initialized to be @@ -69,25 +72,31 @@ /** * \brief Initializes the matrix with the specified dimension and data. * * \param rows The number of rows for the matrix * \param columns The number of colums for the matrix + * \param data The first double of the data for the matrix. The data is in the + * format rows-columns. * \return An initialized OFDoubleMatrix */ - initWithRows: (size_t)rows - columnsAndData: (size_t)columns, ...; + columns: (size_t)columns + data: (double)data, ...; /** * \brief Initializes the matrix with the specified dimension and arguments. * * \param rows The number of rows for the matrix * \param columns The number of colums for the matrix + * \param data The first double of the data for the matrix. The data is in the + * format rows-columns. * \param arguments A va_list with data for the matrix * \return An initialized OFDoubleMatrix */ - initWithRows: (size_t)rows columns: (size_t)columns + data: (double)data arguments: (va_list)arguments; /** * \brief Sets the value for the specified row and colmn. * Index: src/OFDoubleMatrix.m ================================================================== --- src/OFDoubleMatrix.m +++ src/OFDoubleMatrix.m @@ -46,18 +46,20 @@ return [[[self alloc] initWithRows: rows columns: columns] autorelease]; } + matrixWithRows: (size_t)rows - columnsAndData: (size_t)columns, ... + columns: (size_t)columns + data: (double)data, ... { id ret; va_list arguments; - va_start(arguments, columns); + va_start(arguments, data); ret = [[[self alloc] initWithRows: rows columns: columns + data: data arguments: arguments] autorelease]; va_end(arguments); return ret; } @@ -104,26 +106,29 @@ return self; } - initWithRows: (size_t)rows_ - columnsAndData: (size_t)columns_, ... + columns: (size_t)columns_ + data: (double)data_, ... { id ret; va_list arguments; - va_start(arguments, columns_); + va_start(arguments, data_); ret = [self initWithRows: rows_ columns: columns_ + data: data_ arguments: arguments]; va_end(arguments); return ret; } - initWithRows: (size_t)rows_ columns: (size_t)columns_ + data: (double)data_ arguments: (va_list)arguments { self = [super init]; @try { @@ -143,11 +148,12 @@ for (i = 0; i < rows; i++) { size_t j; for (j = i; j < rows * columns; j += rows) - data[j] = (double)va_arg(arguments, double); + data[j] = (j == 0 + ? data_ : va_arg(arguments, double)); } } @catch (id e) { [self release]; @throw e; } Index: src/OFDoubleVector.h ================================================================== --- src/OFDoubleVector.h +++ src/OFDoubleVector.h @@ -40,13 +40,15 @@ /** * \brief Creates a new vector with the specified dimension and data. * * \param dimension The dimension for the vector + * \param data The first double of the data for the vector * \return A new autoreleased OFDoubleVector */ -+ vectorWithDimensionAndData: (size_t)dimension, ...; ++ vectorWithDimension: (size_t)dimension + data: (double)data, ...; /** * \brief Initializes the vector with the specified dimension. * * \param dimension The dimension for the vector @@ -56,23 +58,27 @@ /** * \brief Initializes the vector with the specified dimension and data. * * \param dimension The dimension for the vector + * \param data The first double of the data for the vector * \return An initialized OFDoubleVector */ -- initWithDimensionAndData: (size_t)dimension, ...; +- initWithDimension: (size_t)dimension + data: (double)data, ...; /** - * \brief Initializes the vector with the specified dimension and arguments. + * \brief Initializes the vector with the specified dimension and data. * * \param dimension The dimension for the vector + * \param The first double of the data for the vector * \param arguments A va_list with data for the vector * \return An initialized OFDoubleVector */ - initWithDimension: (size_t)dimension - arguments: (va_list)arguments; + data: (double)data + arguments: (va_list)arguments; /** * \brief Sets the value for the specified index. * * \param value The value Index: src/OFDoubleVector.m ================================================================== --- src/OFDoubleVector.m +++ src/OFDoubleVector.m @@ -43,17 +43,19 @@ + vectorWithDimension: (size_t)dimension { return [[[self alloc] initWithDimension: dimension] autorelease]; } -+ vectorWithDimensionAndData: (size_t)dimension, ... ++ vectorWithDimension: (size_t)dimension + data: (double)data, ... { id ret; va_list arguments; - va_start(arguments, dimension); + va_start(arguments, data); ret = [[[self alloc] initWithDimension: dimension + data: data arguments: arguments] autorelease]; va_end(arguments); return ret; } @@ -88,24 +90,27 @@ } return self; } -- initWithDimensionAndData: (size_t)dimension_, ... +- initWithDimension: (size_t)dimension_ + data: (double)data_, ... { id ret; va_list arguments; - va_start(arguments, dimension_); + va_start(arguments, data_); ret = [self initWithDimension: dimension_ + data: data_ arguments: arguments]; va_end(arguments); return ret; } - initWithDimension: (size_t)dimension_ + data: (double)data_ arguments: (va_list)arguments { self = [super init]; @try { @@ -119,12 +124,13 @@ if ((data = malloc(dimension * sizeof(double))) == NULL) @throw [OFOutOfMemoryException newWithClass: isa requestedSize: dimension * sizeof(double)]; - for (i = 0; i < dimension; i++) - data[i] = (double)va_arg(arguments, double); + data[0] = data_; + for (i = 1; i < dimension; i++) + data[i] = va_arg(arguments, double); } @catch (id e) { [self release]; @throw e; } Index: src/OFFloatMatrix.h ================================================================== --- src/OFFloatMatrix.h +++ src/OFFloatMatrix.h @@ -46,14 +46,17 @@ /** * \brief Creates a new matrix with the specified dimension and data. * * \param rows The number of rows for the matrix * \param columns The number of colums for the matrix + * \param data The first float of the data for the matrix. The data is in the + * format rows-columns. * \return A new autoreleased OFFloatMatrix */ + matrixWithRows: (size_t)rows - columnsAndData: (size_t)columns, ...; + columns: (size_t)columns + data: (float)data, ...; /** * \brief Initializes the matrix with the specified dimension. * * If the number of rows and columns is equal, the matrix is initialized to be @@ -69,25 +72,31 @@ /** * \brief Initializes the matrix with the specified dimension and data. * * \param rows The number of rows for the matrix * \param columns The number of colums for the matrix + * \param data The first float of the data for the matrix. The data is in the + * format rows-columns. * \return An initialized OFFloatMatrix */ - initWithRows: (size_t)rows - columnsAndData: (size_t)columns, ...; + columns: (size_t)columns + data: (float)data, ...; /** * \brief Initializes the matrix with the specified dimension and arguments. * * \param rows The number of rows for the matrix * \param columns The number of colums for the matrix + * \param data The first float of the data for the matrix. The data is in the + * format rows-columns. * \param arguments A va_list with data for the matrix * \return An initialized OFFloatMatrix */ - initWithRows: (size_t)rows columns: (size_t)columns + data: (float)data arguments: (va_list)arguments; /** * \brief Sets the value for the specified row and colmn. * Index: src/OFFloatMatrix.m ================================================================== --- src/OFFloatMatrix.m +++ src/OFFloatMatrix.m @@ -46,18 +46,20 @@ return [[[self alloc] initWithRows: rows columns: columns] autorelease]; } + matrixWithRows: (size_t)rows - columnsAndData: (size_t)columns, ... + columns: (size_t)columns + data: (float)data, ... { id ret; va_list arguments; - va_start(arguments, columns); + va_start(arguments, data); ret = [[[self alloc] initWithRows: rows columns: columns + data: data arguments: arguments] autorelease]; va_end(arguments); return ret; } @@ -104,26 +106,29 @@ return self; } - initWithRows: (size_t)rows_ - columnsAndData: (size_t)columns_, ... + columns: (size_t)columns_ + data: (float)data_, ... { id ret; va_list arguments; - va_start(arguments, columns_); + va_start(arguments, data_); ret = [self initWithRows: rows_ columns: columns_ + data: data_ arguments: arguments]; va_end(arguments); return ret; } - initWithRows: (size_t)rows_ columns: (size_t)columns_ + data: (float)data_ arguments: (va_list)arguments { self = [super init]; @try { @@ -143,11 +148,12 @@ for (i = 0; i < rows; i++) { size_t j; for (j = i; j < rows * columns; j += rows) - data[j] = (float)va_arg(arguments, double); + data[j] = (j == 0 + ? data_ : (float)va_arg(arguments, double)); } } @catch (id e) { [self release]; @throw e; } Index: src/OFFloatVector.h ================================================================== --- src/OFFloatVector.h +++ src/OFFloatVector.h @@ -40,13 +40,15 @@ /** * \brief Creates a new vector with the specified dimension and data. * * \param dimension The dimension for the vector + * \param data The first float of the data for the vector * \return A new autoreleased OFFloatVector */ -+ vectorWithDimensionAndData: (size_t)dimension, ...; ++ vectorWithDimension: (size_t)dimension + data: (float)data, ...; /** * \brief Initializes the vector with the specified dimension. * * \param dimension The dimension for the vector @@ -56,23 +58,27 @@ /** * \brief Initializes the vector with the specified dimension and data. * * \param dimension The dimension for the vector + * \param data The first float of the data for the vector * \return An initialized OFFloatVector */ -- initWithDimensionAndData: (size_t)dimension, ...; +- initWithDimension: (size_t)dimension + data: (float)data, ...; /** - * \brief Initializes the vector with the specified dimension and arguments. + * \brief Initializes the vector with the specified dimension and data. * * \param dimension The dimension for the vector + * \param The first float of the data for the vector * \param arguments A va_list with data for the vector * \return An initialized OFFloatVector */ - initWithDimension: (size_t)dimension - arguments: (va_list)arguments; + data: (float)data + arguments: (va_list)arguments; /** * \brief Sets the value for the specified index. * * \param value The value Index: src/OFFloatVector.m ================================================================== --- src/OFFloatVector.m +++ src/OFFloatVector.m @@ -43,17 +43,19 @@ + vectorWithDimension: (size_t)dimension { return [[[self alloc] initWithDimension: dimension] autorelease]; } -+ vectorWithDimensionAndData: (size_t)dimension, ... ++ vectorWithDimension: (size_t)dimension + data: (float)data, ... { id ret; va_list arguments; - va_start(arguments, dimension); + va_start(arguments, data); ret = [[[self alloc] initWithDimension: dimension + data: data arguments: arguments] autorelease]; va_end(arguments); return ret; } @@ -88,24 +90,27 @@ } return self; } -- initWithDimensionAndData: (size_t)dimension_, ... +- initWithDimension: (size_t)dimension_ + data: (float)data_, ... { id ret; va_list arguments; - va_start(arguments, dimension_); + va_start(arguments, data_); ret = [self initWithDimension: dimension_ + data: data_ arguments: arguments]; va_end(arguments); return ret; } - initWithDimension: (size_t)dimension_ + data: (float)data_ arguments: (va_list)arguments { self = [super init]; @try { @@ -119,11 +124,12 @@ if ((data = malloc(dimension * sizeof(float))) == NULL) @throw [OFOutOfMemoryException newWithClass: isa requestedSize: dimension * sizeof(float)]; - for (i = 0; i < dimension; i++) + data[0] = data_; + for (i = 1; i < dimension; i++) data[i] = (float)va_arg(arguments, double); } @catch (id e) { [self release]; @throw e; }