Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:25:50+00:00 2026-06-04T18:25:50+00:00

I am writing a numpy/cython program to compute the minors of small matrices (a

  • 0

I am writing a numpy/cython program to compute the minors of small matrices (a lot of them).

My current function looks like (computes the minor of mat wrt. to row ii, col jj):

cdef float minor(np.ndarray[DTYPE_t, ndim = 2] mat,int ii,int jj): 
    rows = range(mat.shape[0])
    col = range(mat.shape[0])
    del rows[ii]
    del col[jj]

    cdef np.ndarray[DTYPE_t, ndim = 2] rM = (mat[rows])[:,col]

    cdef float val =  (-1)**(ii+jj) * np.linalg.det(rM)

    return val

After a little benchmarking, the line

cdef np.ndarray[DTYPE_t, ndim = 2] rM = (mat[rows])[:,col]

Is rather time consuming. Is there a better way to remove one row and one column from an two dimensional array?

Yours,

cp3028

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:25:52+00:00Added an answer on June 4, 2026 at 6:25 pm

    It looks like you’re copying the memory from (mat[rows])[:,col], allocation and copying is a slow process. Is it not possible to simply make the function call np.linalg.deg on the chunks of mat in place, instead of copying it and calculating the determinant on the copy?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a bigger program and getting the determinants of 3x3 matrices as fast
I just changed a program I am writing to hold my data as numpy
Writing Classic ASP code in JScript has a lot going for it: more humane
Writing a python program, and I came up with this error while using the
I have been writing some python extension modules with cython. The extensions I've written
What are the current rules for writing python code that will pass cleanly through
I have a Python program that processes fairly large NumPy arrays (in the hundreds
As part of a program I'm writing, I need to solve a cubic equation
Writing a lot of these for a listview. Seems a little bloated to first
Writing a function to generate and push some random data inside of the unknown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.