Skip to content

Add a method for adding multiples of matrix rows with upper column bound #40459

@eddie788

Description

@eddie788

Problem Description

The current method add_multiple_of_row adds a multiple of row j to row i, starting from a certain column index. We could end at a certain column index as well.

The same holds for add_multiple_of_column too.

Proposed Solution

Add a new method add_multiple_of_row_end and the corresponding Cython version, maybe something like this

def add_multiple_of_row_end(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t end_col):
    self.check_row_bounds_and_mutability(i, j)
    try:
        s = self._coerce_element(s)
        self.add_multiple_of_row_end_c(i, j, s, end_col)
    except TypeError:
        raise TypeError('[...]')


cdef add_mult_of_row_end_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t end_col):
    cdef Py_ssize_t c
    for c from 0 <= c <= end_col:
        self.set_unsafe(i, c, self.get_unsafe(i, c) + s*self.get_unsafe(j, c))

Alternatives Considered

This seems slightly faster than overloading the original add_multiple_of_row with an end_col parameter.

Additional Information

No response

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions