Question: I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this

```
def prep_matrix(N):
    I_N = np.identity(N)
    NV = zeros(N*N - 1)
    # now I want NV[0]=NV[1]=...=NV[N-1]:=I_N

```

but I have no idea how to fill NV with my matrices. What can I do? I found a lot on how to create tridiagonal matrices with scalars, but not with matrix blocks.

Answer: 
Dirty, hacky, inefficient, solution (assumes use of forms authentication):

```
public void Global_BeginRequest(object sender, EventArgs e)
{
    if(
        Context.User != null && 
        !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && 
        Context.Session != null && 
        Context.Session["IAMTRACKED"] == null
    )
    {
        Context.Session["IAMTRACKED"] = new object();
        Application.Lock();
        Application["UsersLoggedIn"] = Application["UsersLoggedIn"] + 1;
        Application.UnLock();
    }
}

```

At a high level, this works by, on every request, checking if the user is logged in and, if so, tags the user as logged in and increments the login. This assumes users cannot log out (if they can, you can add a similar test for users who are logged out and tracked).

This is a horrible way to solve your problem, but it's a working proto-type which demonstrates that your problem is solvable.

Note that this understates logins substantially after an application recycle; logins are much longer term than sessions.
Try this. It may help you.

```
 void Application_Start(object sender, EventArgs e)
{
    Application["cnt"] = 0;
    Application["onlineusers"] = 0;
    // Code that runs on application startup

}

 void Session_Start(object sender, EventArgs e)
{
    Application.Lock();
    Application["cnt"] = (int)Application["cnt"] + 1;

    if(Session["username"] != null)
    {
        Application["onlineusers"] = (int)Application["onlineusers"] + 1;
    }
    else
    {
        Application["onlineusers"] = (int)Application["onlineusers"] - 1;
    }

    Application.UnLock();
    // Code that runs when a new session is started
}

```

now you can display the number of users(Without Loggedin):

```
 <%=Application["cnt"].ToString()%>

```

and number of online users:

```
 <%=Application["onlineusers"].ToString()%>

```