Skip to main content
deleted 8 characters in body
Source Link
Peilonrayz
  • 43.5k
  • 7
  • 76
  • 155

I have written a function to multiply two numpy arrays.

    def ra(self):
        """Multiply Rotation with initial Values"""
        rva = self.r_array() * self.va_array()
        rva = np.sum(rva, axis=1)  # Sum rows of Matrix
        rva = np.array([[rva[0]],  # Transpose Matrix
                        [rva[1]],
                        [rva[2]]])

where:

  • r_array has 3 rows and 3 columns
  • va_array has 3 rows and 1 column

I feel like this should be able to be written in one line. However, self.r_array() * self.va_array() always returns a 3 x 3 array.

Any suggestions would be greatly appreciated.

Cheers

I have written a function to multiply two numpy arrays.

    def ra(self):
        """Multiply Rotation with initial Values"""
        rva = self.r_array() * self.va_array()
        rva = np.sum(rva, axis=1)  # Sum rows of Matrix
        rva = np.array([[rva[0]],  # Transpose Matrix
                        [rva[1]],
                        [rva[2]]])

where:

  • r_array has 3 rows and 3 columns
  • va_array has 3 rows and 1 column

I feel like this should be able to be written in one line. However, self.r_array() * self.va_array() always returns a 3 x 3 array.

Any suggestions would be greatly appreciated.

Cheers

I have written a function to multiply two numpy arrays.

def ra(self):
    """Multiply Rotation with initial Values"""
    rva = self.r_array() * self.va_array()
    rva = np.sum(rva, axis=1)  # Sum rows of Matrix
    rva = np.array([[rva[0]],  # Transpose Matrix
                    [rva[1]],
                    [rva[2]]])

where:

  • r_array has 3 rows and 3 columns
  • va_array has 3 rows and 1 column

I feel like this should be able to be written in one line. However, self.r_array() * self.va_array() always returns a 3 x 3 array.

Any suggestions would be greatly appreciated.

Cheers

edited tags
Link
Peilonrayz
  • 43.5k
  • 7
  • 76
  • 155
Source Link

Multiplying numpy arrays

I have written a function to multiply two numpy arrays.

    def ra(self):
        """Multiply Rotation with initial Values"""
        rva = self.r_array() * self.va_array()
        rva = np.sum(rva, axis=1)  # Sum rows of Matrix
        rva = np.array([[rva[0]],  # Transpose Matrix
                        [rva[1]],
                        [rva[2]]])

where:

  • r_array has 3 rows and 3 columns
  • va_array has 3 rows and 1 column

I feel like this should be able to be written in one line. However, self.r_array() * self.va_array() always returns a 3 x 3 array.

Any suggestions would be greatly appreciated.

Cheers