Overview
Comment: | Reduce ObjC method calls in OFFloatVector and OFFloatMatrix. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f4313d070a1278d8d79fc14bc319a51e |
User & Date: | js on 2011-06-13 14:08:58 |
Other Links: | manifest | tags |
Context
2011-06-13
| ||
21:28 | Fix a typo in README. check-in: 31ad00b702 user: js tags: trunk | |
14:08 | Reduce ObjC method calls in OFFloatVector and OFFloatMatrix. check-in: f4313d070a user: js tags: trunk | |
03:47 | Fix -[conformsToProtocol:] for the old GNU runtime. check-in: a1769f0105 user: js tags: trunk | |
Changes
Modified src/OFFloatMatrix.h from [40205a6dae] to [8345b9957a].
︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | + | @class OFFloatVector; /** * \brief A class for storing and manipulating matrices of floats. */ @interface OFFloatMatrix: OFObject <OFCopying> { @public size_t rows, columns; float *data; } /** * \brief Creates a new matrix with the specified dimension. * |
︙ |
Modified src/OFFloatMatrix.m from [a7338c48b5] to [d37cee00b5].
︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | + + | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <math.h> #import "OFFloatMatrix.h" #import "OFFloatVector.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "macros.h" @implementation OFFloatMatrix + matrixWithRows: (size_t)rows columns: (size_t)columns |
︙ | |||
65 66 67 68 69 70 71 | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | - + + - - + + + + | { self = [super init]; @try { rows = rows_; columns = columns_; |
︙ | |||
115 116 117 118 119 120 121 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | - - + + + - - - + + + + + + + + + + + | @try { size_t i; rows = rows_; columns = columns_; |
︙ | |||
310 311 312 313 314 315 316 | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | - - + + + + | float *newData; size_t i, base1, base2; if (rows != matrix->columns) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; |
︙ | |||
340 341 342 343 344 345 346 | 356 357 358 359 360 361 362 363 364 365 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 | - + - + - + + + + + - + | base3++; } base1 += rows; base2 += matrix->rows; } |
︙ |
Modified src/OFFloatVector.m from [5ca73ec320] to [b49ac3419e].
︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | + + + + + + + + + + | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <math.h> #import "OFFloatVector.h" #import "OFFloatMatrix.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "macros.h" static Class floatMatrix = Nil; @implementation OFFloatVector + (void)initialize { if (self == [OFFloatVector class]) floatMatrix = [OFFloatMatrix class]; } + vectorWithDimension: (size_t)dimension { return [[[self alloc] initWithDimension: dimension] autorelease]; } + vectorWithDimensionAndData: (size_t)dimension, ... { |
︙ | |||
59 60 61 62 63 64 65 | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | + + - - + + + + + | - initWithDimension: (size_t)dimension_ { self = [super init]; @try { dimension = dimension_; if (SIZE_MAX / dimension < sizeof(float)) @throw [OFOutOfRangeException newWithClass: isa]; |
︙ | |||
94 95 96 97 98 99 100 | 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 139 140 141 142 143 144 145 146 | + + - - + + + + + + + + + + + + | self = [super init]; @try { size_t i; dimension = dimension_; if (SIZE_MAX / dimension < sizeof(float)) @throw [OFOutOfRangeException newWithClass: isa]; |
︙ | |||
317 318 319 320 321 322 323 | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | - - + - - + - - - + + + + - - - + - - + + - + - + - + | for (i = 0; i < dimension; i++) data[i] /= magnitude; } - (void)multiplyWithMatrix: (OFFloatMatrix*)matrix { |
Modified src/OFObject.m from [251a843844] to [1d0de2f3be].
︙ | |||
83 84 85 86 87 88 89 | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | - + | #define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + \ (__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1)) #define PRE_IVAR ((struct pre_ivar*)(void*)((char*)self - PRE_IVAR_ALIGN)) static struct { Class isa; } alloc_failed_exception; |
︙ | |||
783 784 785 786 787 788 789 | 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | - - + + - + | - autorelease { /* * Cache OFAutoreleasePool since class lookups are expensive with the * GNU runtime. */ |
︙ |