Code: Select all
#Include Once "fbc-int/array.bi"
Declare Sub print_matrix Overload(x() As Single, Byref frmt As String)
Declare Sub print_matrix Overload(x() As Double, Byref frmt As String)
Declare Sub print_matrix Overload(x() As Long, Byref frmt As String)
Declare Sub print_matrix Overload(x() As Integer, Byref frmt As String)
Declare Sub print_matrix Overload(x() As Longint, Byref frmt As String)
Sub print_matrix(x() As Single, Byref frmt As String)
#if __FB_VER_MINOR__ = 7
Dim As Const FBC.FBARRAY Ptr pd = fb_ArrayGetDesc(x())
#elseif __FB_VER_MINOR__ >= 8
Dim As Const FBC.FBARRAY Ptr pd = FBC.ArrayDescriptorPtr(x())
#endif
If pd->dimensions=1 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
Print Using frmt;x(i);
Next
Print
Elseif pd->dimensions=2 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
For j As Integer=pd->dimTb(1).lbound To pd->dimTb(1).ubound
Print Using frmt;x(i,j);
Next
Print
Next
End If
End Sub
Sub print_matrix(x() As Double, Byref frmt As String)
#if __FB_VER_MINOR__ = 7
Dim As Const FBC.FBARRAY Ptr pd = fb_ArrayGetDesc(x())
#elseif __FB_VER_MINOR__ >= 8
Dim As Const FBC.FBARRAY Ptr pd = FBC.ArrayDescriptorPtr(x())
#endif
If pd->dimensions=1 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
Print Using frmt;x(i);
Next
Print
Elseif pd->dimensions=2 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
For j As Integer=pd->dimTb(1).lbound To pd->dimTb(1).ubound
Print Using frmt;x(i,j);
Next
Print
Next
End If
End Sub
Sub print_matrix (x() As Long, Byref frmt As String)
#if __FB_VER_MINOR__ = 7
Dim As Const FBC.FBARRAY Ptr pd = fb_ArrayGetDesc(x())
#elseif __FB_VER_MINOR__ >= 8
Dim As Const FBC.FBARRAY Ptr pd = FBC.ArrayDescriptorPtr(x())
#endif
If pd->dimensions=1 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
Print Using frmt;x(i);
Next
Print
Elseif pd->dimensions=2 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
For j As Integer=pd->dimTb(1).lbound To pd->dimTb(1).ubound
Print Using frmt;x(i,j);
Next
Print
Next
End If
End Sub
Sub print_matrix (x() As Integer, Byref frmt As String)
#if __FB_VER_MINOR__ = 7
Dim As Const FBC.FBARRAY Ptr pd = fb_ArrayGetDesc(x())
#elseif __FB_VER_MINOR__ >= 8
Dim As Const FBC.FBARRAY Ptr pd = FBC.ArrayDescriptorPtr(x())
#endif
If pd->dimensions=1 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
Print Using frmt;x(i);
Next
Print
Elseif pd->dimensions=2 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
For j As Integer=pd->dimTb(1).lbound To pd->dimTb(1).ubound
Print Using frmt;x(i,j);
Next
Print
Next
End If
End Sub
Sub print_matrix (x() As Longint, Byref frmt As String)
#if __FB_VER_MINOR__ = 7
Dim As Const FBC.FBARRAY Ptr pd = fb_ArrayGetDesc(x())
#elseif __FB_VER_MINOR__ >= 8
Dim As Const FBC.FBARRAY Ptr pd = FBC.ArrayDescriptorPtr(x())
#endif
If pd->dimensions=1 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
Print Using frmt;x(i);
Next
Print
Elseif pd->dimensions=2 Then
For i As Integer=pd->dimTb(0).lbound To pd->dimTb(0).ubound
For j As Integer=pd->dimTb(1).lbound To pd->dimTb(1).ubound
Print Using frmt;x(i,j);
Next
Print
Next
End If
End Sub
Dim As Double x(1 To 6, 1 To 6) = {{ 1, 6, 15, 20, 15, 6}, _
{1, 7, 21, 35, 35, 21}, _
{1, 8, 28, 56, 70, 56}, _
{1, 9, 36, 84, 126, 126}, _
{1, 10, 45, 120, 210, 252}, _
{1, 11, 55, 165, 330, 462 }}
Dim As Long y(0 To 7) = { 11, 22, 33, 44, 55, 99, -12, -13 }
Dim As Integer z(0 To 5) = { 1, 2, 3, 4, 5, 6 }
Dim As LongInt w(-3 To 3) = { 123, 234, 345, 456, 567, 678, 789 }
print_matrix(x(), "#####.###")
Print "-------------------"
print_matrix(y(), "#####.###")
Print "-------------------"
print_matrix(z(), "#####.###")
Print "-------------------"
print_matrix(w(), "#####.###")
Code: Select all
1.000 6.000 15.000 20.000 15.000 6.000
1.000 7.000 21.000 35.000 35.000 21.000
1.000 8.000 28.000 56.000 70.000 56.000
1.000 9.000 36.000 84.000 126.000 126.000
1.000 10.000 45.000 120.000 210.000 252.000
1.000 11.000 55.000 165.000 330.000 462.000
-------------------
11.000 22.000 33.000 44.000 55.000 99.000 -12.000 -13.000
-------------------
1.000 2.000 3.000 4.000 5.000 6.000
-------------------
123.000 234.000 345.000 456.000 567.000 678.000 789.000