File size: 25,484 Bytes
e89a301 | 1 2 3 4 5 6 7 8 9 10 11 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 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 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 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 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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | [
{
"function_name": "MatrixMultiplier.__init__",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "__init__",
"functionality": "Initializes the base class (object).",
"input": "A (matrix)",
"output": "None",
"location_or_namespace": "super"
},
{
"function_call_name": "len",
"functionality": "Returns the number of rows of the matrix.",
"input": "A (matrix)",
"output": "int (number of rows)",
"location_or_namespace": "builtins"
}
]
},
{
"function_name": "NaiveMultiplier.multiply",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "dot",
"functionality": "Computes the dot product of two arrays (vector-matrix multiplication).",
"input": "v (vector), self.A (matrix)",
"output": "numpy.ndarray (result of multiplication)",
"location_or_namespace": "numpy"
}
]
},
{
"function_name": "NaiveMultiplier.dump",
"file_path": "multipliers_np.py",
"function_calls": []
},
{
"function_name": "NaiveMultiplier.load",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "NaiveMultiplier.__init__",
"functionality": "Initializes a new NaiveMultiplier object with the given data as matrix A.",
"input": "A=data (matrix data)",
"output": "NaiveMultiplier instance",
"location_or_namespace": "multipliers_np.NaiveMultiplier"
}
]
},
{
"function_name": "RSRBinaryMultiplier.__init__",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "__init__",
"functionality": "Initializes the base class (MatrixMultiplier).",
"input": "A (matrix)",
"output": "None",
"location_or_namespace": "super"
},
{
"function_call_name": "log",
"functionality": "Calculates the logarithm base 2 of a number.",
"input": "self.n (number of rows), 2 (base)",
"output": "float",
"location_or_namespace": "math"
},
{
"function_call_name": "int",
"functionality": "Converts a floating-point number to an integer.",
"input": "float_value",
"output": "int",
"location_or_namespace": "builtins"
},
{
"function_call_name": "preprocess",
"functionality": "Orchestrates the preprocessing steps of the RSR algorithm for the binary matrix, including padding, column blocking, permutation, and segmentation.",
"input": "self.k (blocking parameter)",
"output": "tuple (blocks_permutations, padding)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
}
]
},
{
"function_name": "RSRBinaryMultiplier.find_permutations",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "lexsort",
"functionality": "Performs an indirect stable sort on multiple keys, effectively sorting rows lexicographically.",
"input": "matrix.T[::-1] (transposed matrix with rows reversed)",
"output": "numpy.ndarray (sorted indices)",
"location_or_namespace": "numpy"
}
]
},
{
"function_name": "RSRBinaryMultiplier.find_segment_indices",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "full",
"functionality": "Returns a new array of a given shape and type, filled with a specified value.",
"input": "2 ** k (shape), n (fill value), dtype=int",
"output": "numpy.ndarray",
"location_or_namespace": "numpy"
},
{
"function_call_name": "format",
"functionality": "Formats an integer to a binary string with a specified width and leading zeros.",
"input": "0 (value), f'0{k}b' (format specifier)",
"output": "str",
"location_or_namespace": "builtins"
},
{
"function_call_name": "map",
"functionality": "Applies the 'str' function to each element in the row.",
"input": "str (function), row (iterable)",
"output": "map object",
"location_or_namespace": "builtins"
},
{
"function_call_name": "str",
"functionality": "Converts an object to its string representation.",
"input": "element (from row)",
"output": "str",
"location_or_namespace": "builtins"
},
{
"function_call_name": "join",
"functionality": "Concatenates strings from an iterable into a single string.",
"input": "iterable of strings (output of map)",
"output": "str",
"location_or_namespace": "builtins.str"
},
{
"function_call_name": "int",
"functionality": "Converts a binary string to an integer.",
"input": "row_str (binary string), 2 (base)",
"output": "int",
"location_or_namespace": "builtins"
},
{
"function_call_name": "range",
"functionality": "Generates a sequence of numbers for iteration.",
"input": "last_row_decimal + 1 (start), current_row_decimal (stop)",
"output": "range object",
"location_or_namespace": "builtins"
}
]
},
{
"function_name": "RSRBinaryMultiplier.generate_binary_matrix",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "array",
"functionality": "Creates a NumPy array from a Python list of lists.",
"input": "list of lists (containing binary representations)",
"output": "numpy.ndarray",
"location_or_namespace": "numpy"
},
{
"function_call_name": "list",
"functionality": "Converts a map object (from binary representation) to a list.",
"input": "map object",
"output": "list",
"location_or_namespace": "builtins"
},
{
"function_call_name": "map",
"functionality": "Applies the 'int' function to each character of a binary string.",
"input": "int (function), binary_repr_output (string)",
"output": "map object",
"location_or_namespace": "builtins"
},
{
"function_call_name": "int",
"functionality": "Converts a character to an integer.",
"input": "char (from binary string)",
"output": "int",
"location_or_namespace": "builtins"
},
{
"function_call_name": "binary_repr",
"functionality": "Returns the binary representation of a number as a string, padded to a specified width.",
"input": "i (number), width=k (width)",
"output": "str (binary string)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "range",
"functionality": "Generates a sequence of numbers from 0 to num_rows-1.",
"input": "num_rows",
"output": "range object",
"location_or_namespace": "builtins"
}
]
},
{
"function_name": "RSRBinaryMultiplier.preprocess",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "pad",
"functionality": "Pads an array with constant values.",
"input": "self.A (matrix), ((0, 0), (0, padding)) (pad widths), mode='constant'",
"output": "numpy.ndarray (padded matrix)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "range",
"functionality": "Generates a sequence of numbers for iterating through column blocks.",
"input": "0 (start), self.m (stop), k (step)",
"output": "range object",
"location_or_namespace": "builtins"
},
{
"function_call_name": "find_permutations",
"functionality": "Sorts rows of a block matrix lexicographically and returns permutation indices.",
"input": "block_matrix",
"output": "numpy.ndarray (permutation indices)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "find_segment_indices",
"functionality": "Calculates segment start indices for each unique binary row in a permuted block.",
"input": "block_matrix, permutations",
"output": "numpy.ndarray (segment indices)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "asizeof",
"functionality": "Calculates the approximate size in bytes of a Python object.",
"input": "blocks_permutations (list of tuples)",
"output": "int (size in bytes)",
"location_or_namespace": "pympler.asizeof"
},
{
"function_call_name": "print",
"functionality": "Prints memory information to the console.",
"input": "string (formatted message)",
"output": "None",
"location_or_namespace": "builtins"
}
]
},
{
"function_name": "RSRBinaryMultiplier.multiply",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "empty",
"functionality": "Creates an uninitialized array of a given shape and type.",
"input": "self.m + self._padding (shape), dtype=int",
"output": "numpy.ndarray (results array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "generate_binary_matrix",
"functionality": "Creates the Bin_[k] matrix containing all possible binary values.",
"input": "self.k (blocking parameter)",
"output": "numpy.ndarray (Bin_[k] matrix)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "NaiveMultiplier.__init__",
"functionality": "Initializes a NaiveMultiplier object for performing block products.",
"input": "binary_matrix (Bin_[k] matrix)",
"output": "NaiveMultiplier instance",
"location_or_namespace": "multipliers_np.NaiveMultiplier"
},
{
"function_call_name": "enumerate",
"functionality": "Returns an enumerate object, yielding index-value pairs from an iterable.",
"input": "self._blocks_permutations (list of (permutation, segment_indices) tuples)",
"output": "enumerate object",
"location_or_namespace": "builtins"
},
{
"function_call_name": "empty",
"functionality": "Creates an uninitialized array for segmented_sum.",
"input": "2 ** self.k (shape)",
"output": "numpy.ndarray (segmented_sum array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "cumsum",
"functionality": "Computes the cumulative sum of array elements along a given axis.",
"input": "permuted_vector",
"output": "numpy.ndarray (cumulative sum array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "insert",
"functionality": "Inserts values along the given axis before the given indices.",
"input": "cumsum_arr (array), 0 (index), 0 (value)",
"output": "numpy.ndarray (modified cumulative sum array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "len",
"functionality": "Returns the length of the segment_indices list.",
"input": "segment_indices",
"output": "int (length)",
"location_or_namespace": "builtins"
},
{
"function_call_name": "len",
"functionality": "Returns the length of the cumsum_arr array.",
"input": "cumsum_arr",
"output": "int (length)",
"location_or_namespace": "builtins"
},
{
"function_call_name": "multiply",
"functionality": "Performs vector-matrix multiplication for a block using the naive approach (segmented_sum . Bin_[k]).",
"input": "segmented_sum",
"output": "numpy.ndarray (block product result)",
"location_or_namespace": "multipliers_np.NaiveMultiplier"
}
]
},
{
"function_name": "RSRBinaryMultiplier.dump",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "concatenate",
"functionality": "Joins a sequence of arrays along an existing axis.",
"input": "(per, seg) (permutation and segment arrays)",
"output": "numpy.ndarray (concatenated array)",
"location_or_namespace": "numpy"
}
]
},
{
"function_name": "RSRBinaryMultiplier.load",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "RSRBinaryMultiplier.__init__",
"functionality": "Initializes a new RSRBinaryMultiplier object with preloaded data.",
"input": "None (no matrix or k provided at initialization)",
"output": "RSRBinaryMultiplier instance",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
}
]
},
{
"function_name": "RSRTernaryMultiplier.__init__",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "__init__",
"functionality": "Initializes the base class (MatrixMultiplier).",
"input": "A (matrix)",
"output": "None",
"location_or_namespace": "super"
},
{
"function_call_name": "unpack_matrices",
"functionality": "Decomposes a ternary matrix into two binary matrices (B1 for 1s, B2 for -1s).",
"input": "A (ternary matrix)",
"output": "tuple (B1, B2)",
"location_or_namespace": "multipliers_np.RSRTernaryMultiplier"
},
{
"function_call_name": "RSRBinaryMultiplier.__init__",
"functionality": "Initializes an RSR Binary Multiplier object for the first decomposed binary matrix (B1).",
"input": "self._B1 (binary matrix), k=k (blocking parameter)",
"output": "RSRBinaryMultiplier instance",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "RSRBinaryMultiplier.__init__",
"functionality": "Initializes an RSR Binary Multiplier object for the second decomposed binary matrix (B2).",
"input": "self._B2 (binary matrix), k=k (blocking parameter)",
"output": "RSRBinaryMultiplier instance",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
}
]
},
{
"function_name": "RSRTernaryMultiplier.__binary_multiplier_class__",
"file_path": "multipliers_np.py",
"function_calls": []
},
{
"function_name": "RSRTernaryMultiplier.unpack_matrices",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "astype",
"functionality": "Copies the boolean array (from matrix comparison) and casts its elements to integers (0 or 1).",
"input": "int (type to cast to)",
"output": "numpy.ndarray (binary matrix)",
"location_or_namespace": "numpy.ndarray"
},
{
"function_call_name": "astype",
"functionality": "Copies the boolean array (from matrix comparison) and casts its elements to integers (0 or 1).",
"input": "int (type to cast to)",
"output": "numpy.ndarray (binary matrix)",
"location_or_namespace": "numpy.ndarray"
}
]
},
{
"function_name": "RSRTernaryMultiplier.multiply",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "multiply",
"functionality": "Performs vector-matrix multiplication using the RSR binary algorithm for the first binary matrix (B1).",
"input": "v (vector)",
"output": "numpy.ndarray (result of multiplication)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "multiply",
"functionality": "Performs vector-matrix multiplication using the RSR binary algorithm for the second binary matrix (B2).",
"input": "v (vector)",
"output": "numpy.ndarray (result of multiplication)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
}
]
},
{
"function_name": "RSRTernaryMultiplier.dump",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "dump",
"functionality": "Dumps the preprocessed data for the first internal RSR binary multiplier.",
"input": "None",
"output": "tuple (serialized data)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "dump",
"functionality": "Dumps the preprocessed data for the second internal RSR binary multiplier.",
"input": "None",
"output": "tuple (serialized data)",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
}
]
},
{
"function_name": "RSRTernaryMultiplier.load",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "load",
"functionality": "Loads (deserializes) an RSRBinaryMultiplier instance from data.",
"input": "data[0] (serialized data for B1)",
"output": "RSRBinaryMultiplier instance",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "load",
"functionality": "Loads (deserializes) an RSRBinaryMultiplier instance from data.",
"input": "data[1] (serialized data for B2)",
"output": "RSRBinaryMultiplier instance",
"location_or_namespace": "multipliers_np.RSRBinaryMultiplier"
},
{
"function_call_name": "RSRTernaryMultiplier.__init__",
"functionality": "Initializes a new RSRTernaryMultiplier object.",
"input": "None",
"output": "RSRTernaryMultiplier instance",
"location_or_namespace": "multipliers_np.RSRTernaryMultiplier"
}
]
},
{
"function_name": "RSRPlusPlusBinaryMultiplier._faster_mult",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "empty",
"functionality": "Creates an uninitialized array for storing results of the optimized block product.",
"input": "self.k (shape)",
"output": "numpy.ndarray",
"location_or_namespace": "numpy"
},
{
"function_call_name": "range",
"functionality": "Generates a sequence of numbers for iterative computation (loop for k to 1).",
"input": "self.k (start), 0 (stop), -1 (step)",
"output": "range object",
"location_or_namespace": "builtins"
},
{
"function_call_name": "sum",
"functionality": "Calculates the sum of elements at odd indices of the segmented_sum array.",
"input": "segmented_sum[1::2] (sliced array)",
"output": "int or float",
"location_or_namespace": "numpy"
}
]
},
{
"function_name": "RSRPlusPlusBinaryMultiplier.multiply",
"file_path": "multipliers_np.py",
"function_calls": [
{
"function_call_name": "empty",
"functionality": "Creates an uninitialized array for storing the final results of the multiplication.",
"input": "self.m + self._padding (shape), dtype=int",
"output": "numpy.ndarray",
"location_or_namespace": "numpy"
},
{
"function_call_name": "enumerate",
"functionality": "Returns an enumerate object, yielding index-value pairs from an iterable.",
"input": "self._blocks_permutations (list of (permutation, segment_indices) tuples)",
"output": "enumerate object",
"location_or_namespace": "builtins"
},
{
"function_call_name": "empty",
"functionality": "Creates an uninitialized array for segmented_sum.",
"input": "2 ** self.k (shape)",
"output": "numpy.ndarray (segmented_sum array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "cumsum",
"functionality": "Computes the cumulative sum of array elements along a given axis.",
"input": "permuted_vector",
"output": "numpy.ndarray (cumulative sum array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "insert",
"functionality": "Inserts values along the given axis before the given indices.",
"input": "cumsum_arr (array), 0 (index), 0 (value)",
"output": "numpy.ndarray (modified cumulative sum array)",
"location_or_namespace": "numpy"
},
{
"function_call_name": "len",
"functionality": "Returns the length of the segment_indices list.",
"input": "segment_indices",
"output": "int (length)",
"location_or_namespace": "builtins"
},
{
"function_call_name": "len",
"functionality": "Returns the length of the cumsum_arr array.",
"input": "cumsum_arr",
"output": "int (length)",
"location_or_namespace": "builtins"
},
{
"function_call_name": "_faster_mult",
"functionality": "Implements an optimized way to compute the block product (segmented_sum . Bin_[k]) for RSR++.",
"input": "segmented_sum",
"output": "numpy.ndarray (block product result)",
"location_or_namespace": "multipliers_np.RSRPlusPlusBinaryMultiplier"
}
]
},
{
"function_name": "RSRPlusPlusTernaryMultiplier.__binary_multiplier_class__",
"file_path": "multipliers_np.py",
"function_calls": []
}
] |