Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG-material-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Walter, Wolfgang
PROG-material-public
Commits
cbd29fa8
Commit
cbd29fa8
authored
3 months ago
by
dali662d
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
35297195
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sonderuebung/WiSe24-25/SU08_2024_12_10_Arrays-in_UPs/01_matrix_rechnen_mit_UP.f95
+125
-0
125 additions, 0 deletions
...U08_2024_12_10_Arrays-in_UPs/01_matrix_rechnen_mit_UP.f95
with
125 additions
and
0 deletions
Sonderuebung/WiSe24-25/SU08_2024_12_10_Arrays-in_UPs/01_matrix_rechnen_mit_UP.f95
0 → 100644
+
125
−
0
View file @
cbd29fa8
module
mat_rechnen
implicit
none
private
public
::
einlesen
,
spur
,
orthogonal
,
positivteil
,
ausgabe
contains
subroutine
einlesen
(
A
)
integer
,
dimension
(:,:),
intent
(
out
)
::
A
! rueckgabewert
integer
::
i
write
(
*
,
*
)
"Gebe die Eintraege der Matrix zeilenweise ein."
do
i
=
1
,
size
(
A
,
1
)
read
(
*
,
*
)
A
(
i
,:)
end
do
! Alternativ :
! do i = 1, size(A,1) ! Zeilen
! write(*,*) "Zeile", i, ", Eintragsweise"
! do j = 1, size(A, 2) ! Spalten
! read(*,*) A(i,j)
! end do
! end do
end
subroutine
einlesen
function
spur
(
A
)
integer
,
dimension
(:,:),
intent
(
in
)
::
A
integer
::
spur
! rueckgabewert
integer
::
i
spur
=
0
do
i
=
1
,
size
(
A
,
1
)
spur
=
spur
+
A
(
i
,
i
)
end
do
end
function
spur
function
orthogonal
(
A
)
integer
,
dimension
(:,:),
intent
(
in
)
::
A
logical
::
orthogonal
! rueckgabewert
integer
,
dimension
(
size
(
A
,
1
),
size
(
A
,
1
))
::
I
integer
::
j
! Einheitsmatrix anlegen
I
=
0
do
j
=
1
,
size
(
A
,
1
)
I
(
j
,
j
)
=
1
end
do
orthogonal
=
all
(
matmul
(
A
,
transpose
(
A
))
==
I
)
end
function
orthogonal
function
positivteil
(
A
)
integer
,
dimension
(:,:),
intent
(
in
)
::
A
integer
,
dimension
(
size
(
A
,
1
),
size
(
A
,
1
))
::
positivteil
! rueckgabewert
integer
::
i
,
j
do
i
=
1
,
size
(
A
,
1
)
do
j
=
1
,
size
(
A
,
1
)
if
(
A
(
i
,
j
)
>
0
)
then
positivteil
(
i
,
j
)
=
A
(
i
,
j
)
else
! A(i,j) <= 0
positivteil
(
i
,
j
)
=
0
end
if
end
do
end
do
end
function
positivteil
subroutine
ausgabe
(
A
)
integer
,
dimension
(:,:),
intent
(
in
)
::
A
integer
::
i
do
i
=
1
,
size
(
A
,
1
)
write
(
*
,
*
)
A
(
i
,:)
end
do
end
subroutine
ausgabe
end
module
mat_rechnen
program
matrizen
use
mat_rechnen
implicit
none
integer
,
allocatable
,
dimension
(:,:)
::
A
integer
::
n
! Einlesen Dimension Matrix
write
(
*
,
*
)
"Wie gross soll die Matrix sein?"
do
read
(
*
,
*
)
n
if
(
n
>
0
)
exit
write
(
*
,
*
)
"Fehler: n <= 0! Erneute Eingabe."
end
do
! Allokieren der Matrix als nxn-Matrix
allocate
(
A
(
n
,
n
))
call
einlesen
(
A
)
write
(
*
,
*
)
"Die Spur der Matrix ist "
,
spur
(
A
)
if
(
orthogonal
(
A
))
then
write
(
*
,
*
)
"Die Matrix ist orthogonal."
else
write
(
*
,
*
)
"Die Matrix ist nicht orthogonal."
end
if
write
(
*
,
*
)
"Der Positivteil der Matrix ist :"
call
ausgabe
(
positivteil
(
A
))
! Deallokieren nicht vergessen
deallocate
(
A
)
end
program
matrizen
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment