Solved

Matrix discretisation routine in C

Posted on 2001-07-09
4
263 Views
Last Modified: 2006-11-17
Looking for the EFFICIENT algorithm implimented in C.
0
Comment
Question by:john_t
  • 3
4 Comments
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6269104
state-space matrices?
0
 

Author Comment

by:john_t
ID: 6270133
yes
0
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6270164
If you have access to MATLAB, have a look at MATLAB c2d command. They use matrix discretization using matrix exponentials but for you it will be very difficult to implement.

I know 3 routines do this. The good one is in Fortran (not in C) and it is easy to understand. I'll get it tomorrow.
0
 
LVL 4

Accepted Solution

by:
prashant_n_mhatre earned 200 total points
ID: 6272990
Here it goes...
If you don't understand terminology...let me know..


c     returns the discretized state and input transition matrices

     subroutine discret(a,b,delt,phi,gam,nord,ni)
     implicit real*8(a-h,o-z)

     dimension si(100,100),q(100,100),sb(100,100),prod(100,100)
     dimension a(100,100),b(100,15)
     dimension phi(100,100),gam(100,15)

     do i=1,nord
        q(i,i)=1.0
        si(i,i)=q(i,i)
      end do

     do k=150,1,-1
        if(k.eq.1) then
           call matmul(si,b,nord,nord,ni,sb,100,100,100)
           do i=1,nord
              do j=1,ni
                     gam(i,j)=sb(i,j)*delt
               end do
            end do
           call matmul(a,si,nord,nord,nord,prod,100,100,100)
           do i=1,nord+1
              do j=1,nord+1
                     phi(i,j)=prod(i,j)*delt+q(i,j)
               end do
            end do
        else
           call matmul(a,si,nord+1,nord+1,nord+1,prod,100,100,100)
           do i=1,nord+1
              do j=1,nord+1
                     si(i,j)=q(i,j)+prod(i,j)*delt/float(k)
               end do
            end do
        endif
      end do

     return
     end

c     _______________________________________________________________________________
c     subroutine to obtain the product of two matrices
     
     subroutine matmul(a2,b2,m3,n3,iq,c1,ia,ib,ic)
     implicit real*8(a-h,o-z)

     dimension a2(ia,1),b2(ib,1),c1(ic,1)

     do i=1,m3
        do j=1,iq
           c1(i,j)=0.0
           do k=1,n3
                  c1(i,j)=c1(i,j)+a2(i,k)*b2(k,j)
            end do
         end do
      end do

     return
     end
c     _______________________________________________________________________________

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 63
sumDigits  challenge 7 74
How Complex Is This Java Course ? 9 93
PHP question(s) about order of output 9 57
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now