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
8ef2e273
Commit
8ef2e273
authored
7 years ago
by
Felix Hilsky
Browse files
Options
Downloads
Patches
Plain Diff
Beginn einführung zu interfaces und typen
parent
385f8a70
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
einfuehrung_mod.txt
+55
-0
55 additions, 0 deletions
einfuehrung_mod.txt
with
55 additions
and
0 deletions
einfuehrung_mod.txt
0 → 100644
+
55
−
0
View file @
8ef2e273
„in Blatt 5 werden Module um weitere Features ergänzt
Typen: wir wissen: Variablen haben Typen, z.B. INTEGER, REAL, CHARACTER, LOGICAL
neu: wir können eigene Typen deklarieren. Variablen von selbstdefinierten Typen
bestehen aus mehreren Werten, z.B.“
MODULE quaternionen
IMPLICIT NONE
TYPE quat ! Quaternionen, sowas aehnliches wie komplexe Zahlen mit 4 Dimensionen
REAL :: reell, imag, jmag, kmag
END TYPE
CONTAINS
END MODULE
„um eine Variable von diesem Typ zu deklarieren, nutze TYPE(quaternionen),
z.B. für Modulvariablen
Um ein Objekt von diesem Typ zu erstellen, nutze den Konstruktor mit dem Namen
des Typs und als Argumente die Werte der Bestandteile“
MODULE quaternionen
...
TYPE (quat), PARAMETER :: eins = quat(1, 0, 0, 0)
TYPE (quat), PARAMETER :: i = quat(0, 1, 0, 0)
TYPE (quat), PARAMETER :: j = quat(0, 0, 1, 0)
TYPE (quat), PARAMETER :: k = quat(0, 0, 0, 1)
CONTAINS
END MODULE
„Quaternionen sind ein Körper, die man addieren und multiplizieren können möchte
Um auf Bestandteile von selbstdefinierten Typen zurückzugreifen, nutze %“
MODULE
...
CONTAINS
FUNCTION add(a, b)
TYPE(quaternionen), INTENT(IN) :: a, b
TYPE(quaternionen) :: add
add%reell = a%reell + b%reell
add%imag = a%imag + b%imag
add%jmag = a%jmag + b%jmag
add%kmag = a%kmag + b%kmag
END FUNCTION
Interfaces
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