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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:31:05+00:00 2026-05-28T03:31:05+00:00

Is there any implementation of sparse arrays or equivalent lists in Fortran . In

  • 0

Is there any implementation of sparse arrays or equivalent lists in Fortran.

In the stage of computation of large data set we pass say an array of size of n=10000 to a subroutine to do some stuff on them. For example, finding similar elements in it and listing them for each item sequentially. That is, for item one, to find all similar items through the list (array) and to store the resulting marks. The resulting could be large as the list for each element. Note that regarding the criteria the similarity we use is not symmetric which means we need to iterate the evaluation for all items fully. The resulting therefore could be in different length for each according to criteria being used. Storing all the results therefore requires sparse arrays/list which is available in Python as:


R = an array             # an array
L = []                   # list initialization
for e in R:              # iteration on all elements of R 
    r = similars(e,R,criteria)  # r is array & different in size for each element
    L.append(r)          # store the ranks in list L

For simplicity now we use usual arrays in Fortran where for n<=1000 it is n*n. As you see this is a very inefficient idea for larger sizes.
Any solution?

  • 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-28T03:31:05+00:00Added an answer on May 28, 2026 at 3:31 am

    A solution without linked list.

    Here, one assumes that the vectors “r” contain double precision values.

    Notice that this solution uses no pointer, just allocatable arrays, which warrants to avoid memory leaks. The number of reallocations is limited (log2(list%n)) but one accepts to allocate list%result with a size larger than really needed (maximum twice).

    At last, the vectors “r” are duplicated in the list (this is not the case in the python version).

    module extendable_list
    
    implicit none
    
    type result_type
      double precision,allocatable :: vector(:)
    end type
    
    type list_type
      integer :: n
      type(result_type),allocatable :: result(:)
    end type
    
    contains
    
    subroutine append(list,r)
      type(list_type),intent(inout) :: list
      double precision,intent(in)   :: r(:)
      type(result_type),allocatable :: temporary(:)
      integer :: i
      if(.not.allocated(list%result)) then
        allocate(list%result(10))
        list%n=0
      else if(list%n >= size(list%result)) then
        allocate(temporary(2*list%n))
        do i=1,list%n
          call move_alloc(list%result(i)%vector,temporary(i)%vector)
        enddo
        call move_alloc(temporary,list%result)
      endif
      list%n=list%n+1
      allocate(list%result(list%n)%vector(size(r)))
      list%result(list%n)%vector=r
    end subroutine
    
    end module
    
    program main
      use extendable_list
      implicit none
      type(list_type) :: list
      integer :: i
      do i=1,10
        call append(list,(/1.d0,3.d0/))
        call append(list,(/7.d0,-9.d0,45.d0/))
      enddo
      do i=1,list%n
        write(*,*) list%result(i)%vector
      enddo
    end program
    

    Result :

    coul@b10p5001:~/test$ ifort t65.f90
    coul@b10p5001:~/test$ ./a.out
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
       1.00000000000000        3.00000000000000     
       7.00000000000000       -9.00000000000000        45.0000000000000     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any good implementation of ADT library for C programming language? Implementing Lists,
Is there any fast implementation of cryptographically secure pseudorandom number generator (CSPRNG) for C#
Is there any other implementation (e.g. in an OSS project) of a Java SecurityManager
Is there any rabin fingerprint implementation using .NET?
Is there any bittorrent protocol implementation for C#?
Are there any other STaX Writer implementation for C/C++ except libxml2?
Are there any benchmarks that can be used to check if implementation of ANN
Is there any speed/space/general performance gains in using array based implementation of a binary
Is there any reliable and simple priority queue (linked list preferred, not necessary) implementation
Does any one know if there is kinda implementation/addon for VS 2008 SP1 for

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.