ObjFW  Check-in [e129012224]

Overview
Comment:Nicer initializers for OF{Double,Float}{Matrix,Vector}.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e129012224d75fe42f4af8131db9f6146f08cf99d39a5be3955bd1aa5ffd4c38
User & Date: js on 2011-06-30 12:36:29
Other Links: manifest | tags
Context
2011-06-30
23:24
Update ChangeLog. check-in: 558a10fff3 user: js tags: trunk
12:36
Nicer initializers for OF{Double,Float}{Matrix,Vector}. check-in: e129012224 user: js tags: trunk
2011-06-29
21:16
objfw-compile: Pass -f flags to the compiler. check-in: 4450b2d98a user: js tags: trunk
Changes

Modified src/OFDoubleMatrix.h from [bebe1dd4bc] to [494f2e0562].

44
45
46
47
48
49
50


51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73


74
75
76
77

78
79
80
81
82
83


84
85
86
87
88

89
90
91
92
93
94
95
	 columns: (size_t)columns;

/**
 * \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


 * \return A new autoreleased OFDoubleMatrix
 */
+ matrixWithRows: (size_t)rows
  columnsAndData: (size_t)columns, ...;


/**
 * \brief Initializes the matrix with the specified dimension.
 *
 * If the number of rows and columns is equal, the matrix is initialized to be
 * the identity.
 *
 * \param rows The number of rows for the matrix
 * \param columns The number of colums for the matrix
 * \return An initialized OFDoubleMatrix
 */
- initWithRows: (size_t)rows
       columns: (size_t)columns;

/**
 * \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


 * \return An initialized OFDoubleMatrix
 */
-   initWithRows: (size_t)rows
  columnsAndData: (size_t)columns, ...;


/**
 * \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 arguments A va_list with data for the matrix
 * \return An initialized OFDoubleMatrix
 */
- initWithRows: (size_t)rows
       columns: (size_t)columns

     arguments: (va_list)arguments;

/**
 * \brief Sets the value for the specified row and colmn.
 *
 * \param value The value
 * \param row The row for the value







>
>



|
>



















>
>



|
>






>
>





>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
	 columns: (size_t)columns;

/**
 * \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
	 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
 * the identity.
 *
 * \param rows The number of rows for the matrix
 * \param columns The number of colums for the matrix
 * \return An initialized OFDoubleMatrix
 */
- initWithRows: (size_t)rows
       columns: (size_t)columns;

/**
 * \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
	 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.
 *
 * \param value The value
 * \param row The row for the value

Modified src/OFDoubleMatrix.m from [298309e639] to [beb8bdaf1b].

44
45
46
47
48
49
50
51

52
53
54
55
56
57
58

59
60
61
62
63
64
65
	 columns: (size_t)columns
{
	return [[[self alloc] initWithRows: rows
				   columns: columns] autorelease];
}

+ matrixWithRows: (size_t)rows
  columnsAndData: (size_t)columns, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, columns);
	ret = [[[self alloc] initWithRows: rows
				  columns: columns

				arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init







|
>




|


>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	 columns: (size_t)columns
{
	return [[[self alloc] initWithRows: rows
				   columns: columns] autorelease];
}

+ matrixWithRows: (size_t)rows
	 columns: (size_t)columns
	    data: (double)data, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, data);
	ret = [[[self alloc] initWithRows: rows
				  columns: columns
				     data: data
				arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116

117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
		@throw e;
	}

	return self;
}

-   initWithRows: (size_t)rows_
  columnsAndData: (size_t)columns_, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, columns_);
	ret = [self initWithRows: rows_
			 columns: columns_

		       arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithRows: (size_t)rows_
       columns: (size_t)columns_

     arguments: (va_list)arguments
{
	self = [super init];

	@try {
		size_t i;








|
>




|


>








>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
		@throw e;
	}

	return self;
}

-   initWithRows: (size_t)rows_
	 columns: (size_t)columns_
	    data: (double)data_, ...
{
	id ret;
	va_list arguments;

	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 {
		size_t i;

141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(double)];

		for (i = 0; i < rows; i++) {
			size_t j;

			for (j = i; j < rows * columns; j += rows)

				data[j] = (double)va_arg(arguments, double);
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







>
|







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(double)];

		for (i = 0; i < rows; i++) {
			size_t j;

			for (j = i; j < rows * columns; j += rows)
				data[j] = (j == 0
				    ? data_ : va_arg(arguments, double));
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;

Modified src/OFDoubleVector.h from [0337893df4] to [b5c0cb4d21].

38
39
40
41
42
43
44

45
46
47

48
49
50
51
52
53
54
55
56
57
58
59
60

61
62
63

64
65
66
67
68

69
70
71
72

73
74
75
76
77
78
79
80
 */
+ vectorWithDimension: (size_t)dimension;

/**
 * \brief Creates a new vector with the specified dimension and data.
 *
 * \param dimension The dimension for the vector

 * \return A new autoreleased OFDoubleVector
 */
+ vectorWithDimensionAndData: (size_t)dimension, ...;


/**
 * \brief Initializes the vector with the specified dimension.
 *
 * \param dimension The dimension for the vector
 * \return An initialized OFDoubleVector
 */
- initWithDimension: (size_t)dimension;

/**
 * \brief Initializes the vector with the specified dimension and data.
 *
 * \param dimension The dimension for the vector

 * \return An initialized OFDoubleVector
 */
- initWithDimensionAndData: (size_t)dimension, ...;


/**
 * \brief Initializes the vector with the specified dimension and arguments.
 *
 * \param dimension The dimension 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;

/**
 * \brief Sets the value for the specified index.
 *
 * \param value The value
 * \param index The index for the value
 */







>


|
>













>


|
>


|


>




>
|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 */
+ vectorWithDimension: (size_t)dimension;

/**
 * \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
 */
+ vectorWithDimension: (size_t)dimension
		 data: (double)data, ...;

/**
 * \brief Initializes the vector with the specified dimension.
 *
 * \param dimension The dimension for the vector
 * \return An initialized OFDoubleVector
 */
- initWithDimension: (size_t)dimension;

/**
 * \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
 */
- initWithDimension: (size_t)dimension
	       data: (double)data, ...;

/**
 * \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
	       data: (double)data
	  arguments: (va_list)arguments;

/**
 * \brief Sets the value for the specified index.
 *
 * \param value The value
 * \param index The index for the value
 */

Modified src/OFDoubleVector.m from [b4675e8ae3] to [a8ab061699].

41
42
43
44
45
46
47
48

49
50
51
52
53
54

55
56
57
58
59
60
61
}

+ vectorWithDimension: (size_t)dimension
{
	return [[[self alloc] initWithDimension: dimension] autorelease];
}

+ vectorWithDimensionAndData: (size_t)dimension, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, dimension);
	ret = [[[self alloc] initWithDimension: dimension

				     arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init







|
>




|

>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
}

+ vectorWithDimension: (size_t)dimension
{
	return [[[self alloc] initWithDimension: dimension] autorelease];
}

+ vectorWithDimension: (size_t)dimension
		 data: (double)data, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, data);
	ret = [[[self alloc] initWithDimension: dimension
					  data: data
				     arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init
86
87
88
89
90
91
92
93

94
95
96
97
98
99

100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
		[self release];
		@throw e;
	}

	return self;
}

- initWithDimensionAndData: (size_t)dimension_, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, dimension_);
	ret = [self initWithDimension: dimension_

			    arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithDimension: (size_t)dimension_

	  arguments: (va_list)arguments
{
	self = [super init];

	@try {
		size_t i;

		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(double))
			@throw [OFOutOfRangeException newWithClass: isa];

		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);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







|
>




|

>







>

















>
|
|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
		[self release];
		@throw e;
	}

	return self;
}

- initWithDimension: (size_t)dimension_
	       data: (double)data_, ...
{
	id ret;
	va_list arguments;

	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 {
		size_t i;

		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(double))
			@throw [OFOutOfRangeException newWithClass: isa];

		if ((data = malloc(dimension * sizeof(double))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(double)];

		data[0] = data_;
		for (i = 1; i < dimension; i++)
			data[i] = va_arg(arguments, double);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

Modified src/OFFloatMatrix.h from [ff5f178d3a] to [9ef0d27c04].

44
45
46
47
48
49
50


51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73


74
75
76
77

78
79
80
81
82
83


84
85
86
87
88

89
90
91
92
93
94
95
	 columns: (size_t)columns;

/**
 * \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


 * \return A new autoreleased OFFloatMatrix
 */
+ matrixWithRows: (size_t)rows
  columnsAndData: (size_t)columns, ...;


/**
 * \brief Initializes the matrix with the specified dimension.
 *
 * If the number of rows and columns is equal, the matrix is initialized to be
 * the identity.
 *
 * \param rows The number of rows for the matrix
 * \param columns The number of colums for the matrix
 * \return An initialized OFFloatMatrix
 */
- initWithRows: (size_t)rows
       columns: (size_t)columns;

/**
 * \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


 * \return An initialized OFFloatMatrix
 */
-   initWithRows: (size_t)rows
  columnsAndData: (size_t)columns, ...;


/**
 * \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 arguments A va_list with data for the matrix
 * \return An initialized OFFloatMatrix
 */
- initWithRows: (size_t)rows
       columns: (size_t)columns

     arguments: (va_list)arguments;

/**
 * \brief Sets the value for the specified row and colmn.
 *
 * \param value The value
 * \param row The row for the value







>
>



|
>



















>
>



|
>






>
>





>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
	 columns: (size_t)columns;

/**
 * \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
	 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
 * the identity.
 *
 * \param rows The number of rows for the matrix
 * \param columns The number of colums for the matrix
 * \return An initialized OFFloatMatrix
 */
- initWithRows: (size_t)rows
       columns: (size_t)columns;

/**
 * \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
	 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.
 *
 * \param value The value
 * \param row The row for the value

Modified src/OFFloatMatrix.m from [2c065c1145] to [47a5b85ad1].

44
45
46
47
48
49
50
51

52
53
54
55
56
57
58

59
60
61
62
63
64
65
	 columns: (size_t)columns
{
	return [[[self alloc] initWithRows: rows
				   columns: columns] autorelease];
}

+ matrixWithRows: (size_t)rows
  columnsAndData: (size_t)columns, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, columns);
	ret = [[[self alloc] initWithRows: rows
				  columns: columns

				arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init







|
>




|


>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	 columns: (size_t)columns
{
	return [[[self alloc] initWithRows: rows
				   columns: columns] autorelease];
}

+ matrixWithRows: (size_t)rows
	 columns: (size_t)columns
	    data: (float)data, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, data);
	ret = [[[self alloc] initWithRows: rows
				  columns: columns
				     data: data
				arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116

117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
		@throw e;
	}

	return self;
}

-   initWithRows: (size_t)rows_
  columnsAndData: (size_t)columns_, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, columns_);
	ret = [self initWithRows: rows_
			 columns: columns_

		       arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithRows: (size_t)rows_
       columns: (size_t)columns_

     arguments: (va_list)arguments
{
	self = [super init];

	@try {
		size_t i;








|
>




|


>








>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
		@throw e;
	}

	return self;
}

-   initWithRows: (size_t)rows_
	 columns: (size_t)columns_
	    data: (float)data_, ...
{
	id ret;
	va_list arguments;

	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 {
		size_t i;

141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(float)];

		for (i = 0; i < rows; i++) {
			size_t j;

			for (j = i; j < rows * columns; j += rows)

				data[j] = (float)va_arg(arguments, double);
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







>
|







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(float)];

		for (i = 0; i < rows; i++) {
			size_t j;

			for (j = i; j < rows * columns; j += rows)
				data[j] = (j == 0
				    ? data_ : (float)va_arg(arguments, double));
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;

Modified src/OFFloatVector.h from [ad6509aa39] to [8280af769a].

38
39
40
41
42
43
44

45
46
47

48
49
50
51
52
53
54
55
56
57
58
59
60

61
62
63

64
65
66
67
68

69
70
71
72

73
74
75
76
77
78
79
80
 */
+ vectorWithDimension: (size_t)dimension;

/**
 * \brief Creates a new vector with the specified dimension and data.
 *
 * \param dimension The dimension for the vector

 * \return A new autoreleased OFFloatVector
 */
+ vectorWithDimensionAndData: (size_t)dimension, ...;


/**
 * \brief Initializes the vector with the specified dimension.
 *
 * \param dimension The dimension for the vector
 * \return An initialized OFFloatVector
 */
- initWithDimension: (size_t)dimension;

/**
 * \brief Initializes the vector with the specified dimension and data.
 *
 * \param dimension The dimension for the vector

 * \return An initialized OFFloatVector
 */
- initWithDimensionAndData: (size_t)dimension, ...;


/**
 * \brief Initializes the vector with the specified dimension and arguments.
 *
 * \param dimension The dimension 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;

/**
 * \brief Sets the value for the specified index.
 *
 * \param value The value
 * \param index The index for the value
 */







>


|
>













>


|
>


|


>




>
|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 */
+ vectorWithDimension: (size_t)dimension;

/**
 * \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
 */
+ vectorWithDimension: (size_t)dimension
		 data: (float)data, ...;

/**
 * \brief Initializes the vector with the specified dimension.
 *
 * \param dimension The dimension for the vector
 * \return An initialized OFFloatVector
 */
- initWithDimension: (size_t)dimension;

/**
 * \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
 */
- initWithDimension: (size_t)dimension
	       data: (float)data, ...;

/**
 * \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
	       data: (float)data
	  arguments: (va_list)arguments;

/**
 * \brief Sets the value for the specified index.
 *
 * \param value The value
 * \param index The index for the value
 */

Modified src/OFFloatVector.m from [7be4d41cc6] to [a1eb70bd06].

41
42
43
44
45
46
47
48

49
50
51
52
53
54

55
56
57
58
59
60
61
}

+ vectorWithDimension: (size_t)dimension
{
	return [[[self alloc] initWithDimension: dimension] autorelease];
}

+ vectorWithDimensionAndData: (size_t)dimension, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, dimension);
	ret = [[[self alloc] initWithDimension: dimension

				     arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init







|
>




|

>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
}

+ vectorWithDimension: (size_t)dimension
{
	return [[[self alloc] initWithDimension: dimension] autorelease];
}

+ vectorWithDimension: (size_t)dimension
		 data: (float)data, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, data);
	ret = [[[self alloc] initWithDimension: dimension
					  data: data
				     arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init
86
87
88
89
90
91
92
93

94
95
96
97
98
99

100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
		[self release];
		@throw e;
	}

	return self;
}

- initWithDimensionAndData: (size_t)dimension_, ...

{
	id ret;
	va_list arguments;

	va_start(arguments, dimension_);
	ret = [self initWithDimension: dimension_

			    arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithDimension: (size_t)dimension_

	  arguments: (va_list)arguments
{
	self = [super init];

	@try {
		size_t i;

		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(float))
			@throw [OFOutOfRangeException newWithClass: isa];

		if ((data = malloc(dimension * sizeof(float))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(float)];


		for (i = 0; i < dimension; i++)
			data[i] = (float)va_arg(arguments, double);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







|
>




|

>







>

















>
|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
		[self release];
		@throw e;
	}

	return self;
}

- initWithDimension: (size_t)dimension_
	       data: (float)data_, ...
{
	id ret;
	va_list arguments;

	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 {
		size_t i;

		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(float))
			@throw [OFOutOfRangeException newWithClass: isa];

		if ((data = malloc(dimension * sizeof(float))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(float)];

		data[0] = data_;
		for (i = 1; i < dimension; i++)
			data[i] = (float)va_arg(arguments, double);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;