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

  • SEARCH
  • Home
  • 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 7942541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:00:11+00:00 2026-06-04T00:00:11+00:00

I have a mask with a certain numbers of rows and columns. I would

  • 0

I have a mask with a certain numbers of rows and columns.
I would like to read just the (i,j) components that contains for example 1.
Then once the (i,j) component with 1 is found perform four different action if any of the (i+1,j),(i-i,j),(i,j+1),(i,j-1) equal to 1 is found.

Hope this is clear.
Any advice are welcome.
Thanks.

  • 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-04T00:00:13+00:00Added an answer on June 4, 2026 at 12:00 am

    Let your mask be something like this:

    integer, dimension(1:r,1:c) :: mask
    

    Then the following fragment should point you in the right direction:

    forall (i=1:r, j=1:c, mask(i,j)==1)
       if ( mask(i-1,j)==1) then
          ! do the right thing
       else if ( mask(i+1,j)==1) then
          ! I hope you get the picture now
    ...
    

    I’ll leave it to you to deal with the edge cases where +/- i/j step outside the array bounds. forall is not necessarily the fastest construction to use, and we could debate the elegance and readability of using it rather than a sequence of loops, but let’s not.

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

Sidebar

Related Questions

I have <div class=image-mask> <img class=alignright src=image.png /> </div> and I would like to
We have a servlet that needs certain variables like passwords, encryption salts, etc., not
I have this mask : Let's say I would like to make a bitwise_and
I have an XML file looks like this: <?xml version=1.0 encoding=utf-8 ?> <PathMasks> <Mask
I have a users table with a bitmask field that has a permissions mask
I have an input mask on my text box like 000,000,000.00 I have the
I have a page that features certain image thumbs from a custom field. What
If I have a ViewPager with a certain number of pages, what would be
I have mask in textbox 99:99 I need convert to decimal. example: string 12:34
I have a small program that should move the mouse to a certain point

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.