ObjFW  Diff

Differences From Artifact [81cca6b06a]:

To Artifact [a7338c48b5]:


16
17
18
19
20
21
22

23
24
25
26
27
28
29

#include "config.h"

#include <string.h>
#include <math.h>

#import "OFFloatMatrix.h"

#import "OFString.h"

#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"







>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include "config.h"

#include <string.h>
#include <math.h>

#import "OFFloatMatrix.h"
#import "OFFloatVector.h"
#import "OFString.h"

#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"
365
366
367
368
369
370
371















































372
		for (j = i; j < rows * columns; j += rows)
			newData[j] = data[k++];
	}

	[self freeMemory: data];
	data = newData;
}















































@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
		for (j = i; j < rows * columns; j += rows)
			newData[j] = data[k++];
	}

	[self freeMemory: data];
	data = newData;
}

- (void)translateWithVector: (OFFloatVector*)vector
{
	OFFloatMatrix *translation;
	float *cArray;

	if (rows != columns || [vector dimension] != rows - 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	cArray = [vector cArray];
	translation = [[OFFloatMatrix alloc] initWithRows: rows
						  columns: columns];

	memcpy(translation->data + (columns - 1) * rows, cArray,
	    (rows - 1) * sizeof(float));

	@try {
		[self multiplyWithMatrix: translation];
	} @finally {
		[translation release];
	}
}

- (void)scaleWithVector: (OFFloatVector*)vector
{
	OFFloatMatrix *scale;
	float *cArray;
	size_t i, j;

	if (rows != columns || [vector dimension] != rows - 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	cArray = [vector cArray];
	scale = [[OFFloatMatrix alloc] initWithRows: rows
					    columns: columns];

	for (i = j = 0; i < ((rows - 1) * columns) - 1; i += rows + 1)
		scale->data[i] = cArray[j++];

	@try {
		[self multiplyWithMatrix: scale];
	} @finally {
		[scale release];
	}
}
@end