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 6091521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:20:15+00:00 2026-05-23T12:20:15+00:00

I am currently working on a algorithm that needs to find all equal occurrences

  • 0

I am currently working on a algorithm that needs to find all equal occurrences a an item in a matrix. I decided to use uBLAS matrices from boost. So my problem is:

I have a ublas::matrix looking like:

1 2 3 4 5
2 4 6 8 1
1 5 4 6 8
9 4 6 7 0

and I want to find all positions (x,y) of i.e. the value 6.
Is there a function for?

  • 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-05-23T12:20:16+00:00Added an answer on May 23, 2026 at 12:20 pm

    There is no ublas-specific function (as far as I can tell), you will have to scan the matrix the usual way — through iterators or through indexed access:

    typedef std::vector<std::pair<size_t, size_t> > posvec_t;
    template <typename T>
    posvec_t find_all(const ublas::matrix<T>& m, T val)
    {
        posvec_t ret;
        for(size_t r=0; r<m.size1(); ++r)
           for(size_t c=0; c<m.size2(); ++c)
               if(m(r,c) == val)
                   ret.push_back( std::make_pair(r, c) );
        return ret;
    }
    

    test: https://ideone.com/qhW9b

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

Sidebar

Related Questions

I'm currently working on creating a new C# project that needs to interact with
Currently I am working on a project that would use genetic algorithms to optimize
I have an algorithm that searches through all of my sites users, finding those
I am working on an algorithm that performs a global thresholding of an 8-bit
Currently, I am working on a project that is trying to group 3d points
I am currently working on reimplementing some algorithm written in Java in Python. One
Working in C#, I need to find all local peaks in a List of
I'm currently working on this project that implies some DSP skills. I must extract
I'm currently working on a problem that requires the random selection of an element
i am currently working on a approach to parse a site that contains datas

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.